Reputation: 3602
I want to remove words inside bracket, I'm currently using this
【.*】
【remove this】preserve this 【remove this】
but it removes everything for this because there is another bracket
How can I solve this? it also happens on comma
◆.*、
◆ remove this、preserve this、
that regex removes everything because I have 2 commas
Upvotes: 0
Views: 990
Reputation: 4873
You can try two solutions:
Lazy Operators (this might not work on your RegEx parser)
\[.*?\]
.*?,
Or replace . by a negation list to match any element but the end delimiter:
\[[^]]*\]
[^,]*,
Upvotes: 1
Reputation: 476950
Use non-greedy matching with ?
, and also escape the brackets, which are special characters:
\[.*?\]
Upvotes: 4