Reputation: 772
I want to use Regular expression to replace this text :
[Button size="Big" color="#000"] test [/Button]
to Button
, I used this site http://www.freeformatter.com/regex-tester.html but not working the replace.
the Regular expression \[Button([^\]]*)\[/Button]
,it give me the result String is same as before replace!
what the mistake?
Upvotes: 2
Views: 105
Reputation: 213253
The ([^\]]*)
part of your regex will stop matching before the closing ]
of first tag. So, you don't have the pattern to match string - "] test "
thereafter.
Modify your regex to:
\[Button([^\]]*][^\[]*)\[/Button]
Upvotes: 2
Reputation: 4282
The regex of
\[Button.*\]
and the replacement string of Button
should be enough.
Upvotes: 0
Reputation: 18861
Try with this, it matches properly and also matches the insides.
\[Button([^\]]*)\](.*?)\[/Button\]
Upvotes: 1