how to write a correct regular expressions?

how the regex should be written if i want to subsitude the value into it
for example this is the regex i have..
(\\w\\d+ *Months) *(\\d+\\. \\d*)


i want to replace the word Months with exactly a certain string,
like string subsitude="2Months";
then the regex would be something like this...

(\\w\\d+ *subsitude) *(\\d+\\. \\d*)

wat is the proper way to write this





Answer this question

how to write a correct regular expressions?

  • David Ghikas

    Hi

    check your last Post

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=284501&SiteID=1

    I have answered that hope that this will help you out.



  • username199

    I'm not sure what your exact requirements are for that example.

    However, what you must do is use {curly brackets} to break your search expression into one or more groups, and then reference matches in those groups with \1 for the first group, \2 for the second and so on.

    I highly recommend downloading "Regex Builder" from http://www.gotdotnet.com/Workspaces/Workspace.aspx id=9e33c395-8275-4906-8a09-0bff41fdc1d6

    This is a small utility that will allow you to very easily test your regular expressions.

  • dungtv2

    ok..thanks..
  • how to write a correct regular expressions?