c# Regex to match end of string? -


i need generate regex match string has following detail correct:

  1. string should end bracket , numbers inside it.
  2. end bracket should appear once @ end of line , not else.
  3. any characters allowed before bracket start
  4. no characters allowed after bracket end
  5. string should contain 1 set of brackets numbers, i.e. no double brackets (( or ))

i have tried .\([0-9]+\)$ not required.

for example:

following string should match:

asds-xyz (1) asds+-xyz (12) as@ds-xyz (123) 

following strings should not matched:

asds-xyz ((1) asds-xyz ((12sdf)) (123) asds-xyz xyz ((2) xyx (1)) xyz (1)(2) xyz(1)bxz xyz(1)bxz(2) 

^[^\(\)]*\(\d+\)$ 

will job...

\d = [0-9]


Comments