-4

I have the following string:

test text x=String[%sasdasd%] and b= String[%jj%]

Of course I want those regexp for C#.

I want with regexp to be able to get those String[%sasdasd%] and String[%jj%]

That means I want to get all texts that start with String[ and end with ]

What is the best regexp out there?

halfer
  • 19,824
  • 17
  • 99
  • 186
Alen.Toma
  • 4,684
  • 2
  • 14
  • 31

2 Answers2

2

Match all String (literally) followed by open square bracket \[ followed by any character . one or more times +, be lazy about it ? and end with closing square bracket \]

String\[.+?\]
ypsilo0n
  • 576
  • 5
  • 7
2
String\[.*\]

See here for explanation.

Connor
  • 807
  • 1
  • 10
  • 20