Matching using multiple question marks  
Author Message
sakarmo





PostPosted: Regular Expressions, Matching using multiple question marks Top

 I am trying to this regex but I am not. is it possible

help me!!!!

string: x*[2+[(2+y)*z]*(4+y)]-3/[(3+y)*z]
regex:
matches:
2+[(2+y)*z]*(4+y)
(3+y)*z

(Moderator: Thread moved to the Regular Expression Forum and Title tweaked for quicker thread understanding during a search)


.NET Development24  
 
 
Frank Boyne





PostPosted: Regular Expressions, Matching using multiple question marks Top

It appears you are trying to find the string bounded by the outermost pair of square brackets and allowing nested square brackets within the string

Try the expression described in the following blog entry: http://blogs.msdn.com/bclteam/archive/2005/03/15/396452.aspx. The example uses angle brackets as the thing being matched, but you should be able to convert the expression to look for square brackets fairly easily.

Remember that you need to use \[ and \] to represent the actual '[' and ']' characters and be careful to distinguish between the angle brackets that are part of the expression being matched and the angle brackets that are part of the RegEx expression ( <name>subexpression).