.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Regular Expression

Posted By: Asha.MP     Posted Date: September 26, 2010    Points:2   Category :ASP.Net
Hi...

What is the use of \b in the regular expression?

Responses
Author: Jean Paul             
Posted Date: September 27, 2010     Points: 5   

Hello Asha,

\b - specifies to start the match at a word boundary.

Example: To find the occurrence of words ending with 'ing' prefixed by a word character
(\w is added to the left to denote word characters)

string input = "a sentence containing two ing";
string pattern = @"\wing\b"; // 'ing' is our search item \w=any word characters

// Find words ending with 'ing'
var r = Regex.IsMatch(input, pattern);

Regards.

Jean Paul http://jeanpaulva.com/
Author: Asha.MP             
Posted Date: September 27, 2010     Points: 5   

Thank you for your reply..

but which ing it will match?
containing or ing???

Thanks and Regards,
Asha.mp
Author: Jean Paul             
Posted Date: September 28, 2010     Points: 5   

containing will be matched as \wing says any word characters followed by ing.

Regards.

Jean Paul http://jeanpaulva.com/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend