October 12th, 2011, 09:07 AM
Regex problem using replace method for outside area of the matching
I got stick to a regex problem.
I have a string, e.g.
test foo bar [Hello] test foo X:123 foo bar
The value inside the brackets and the brackets themselves must remain. Also the "X:" with the digits following must remain.
The rest should be removed/replaced by using a regular expression.
It may be that only a test in brackets OR the X:123 value appears in a search string.
Using the replace method of the following regular expression it nearly works:
Has anyone an idea how to connect both possibilities (to remain the value in brackets and/or the substring with X:<some digits>)
October 12th, 2011, 11:32 AM
Does the thing in brackets always come before the X:digits?
which leaves you with