c# - problem writing regular expression -


i trying write regular expression matches of following:

{string} {string[]} {string[6]} 

where instead of 6 in last line, there positive integer. also, wherever string appears in above lines, there int.

here regular expression wrote : {(string|int)(([]|[[0-9]])?)}. worked wouldn't allow more 1 digit within square bracket. overcome problem, modified way : {(string|int)(([]|[[0-9]*])?)}.

the modified regex seems having serious problems. matches {string[][]}. can please tell me causes match against this? also, when try enclose [0-9] within paranthesis, exception saying "too many )'s". why happen?

can please tell me how write regular expression satisfy requirements?

note : tryingthis in c#

you need escape special characters {} , []:

\{(string|int)(\[\d*\])?\} 

you might need use [0-9] instead of \d depending on engine use.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -