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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(?<=\+)(?=(?:\{[^}+]*\}|\[ [^]+]*\]|\ ([^)+]*\)) \+).([^+]* )[]})](?=\ +)
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.
ASKER
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?