Link to home
Start Free TrialLog in
Avatar of NevSoFly
NevSoFly

asked on

Is it possible to make this work?

I am using the following pattern "\+\{([^}+]*)\}\+" to find "+{some text}+ and replace it with "+some text+".  To do this I am using "+$1+" as the replacement string.  This works perfectly.  

What I would like to know is if it is possible to change the pattern so that I could just use "$1" instead of "+$1+"?.  If so what would the pattern be?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NevSoFly
NevSoFly

ASKER

Thanks.  I don't know what you mean by "what style of regular expressions" that I am using. But I am coding in VB.net.

I took your solution and it worked so I applied it to "+(some text)+" and "+[some text]+" as well.  I then tried to combine the three to cut down on code:
"(?<=\+)\{([^}+]*)\}|\[([^]+]*)\]|\(([^)+]*)\)(?=\+)"

That didn't work.  Any suggestions or should I post this to a new question?
(?<=\+)(?=(?:\{[^}+]*\}|\[[^]+]*\]|\([^)+]*\))\+).([^+]*)[]})](?=\+)
If you were to add some () brackets around the \+ characters in the pattern (ie "(\+)\{([^}+]*)\}(\+)") then you would capture them and use $1$2$3 as the replacement, but I don't think it's possible to just use $1.