Reputation: 21
I want to remove the apostrophes ' but only those between bracket.
My example is something like this :
'keep apostrophes' ('remove apostrophes')
I proceed like this :
[^a-z()\s]
but then it removes all apostrophes. I don't know a way to combine everything together.
Upvotes: 2
Views: 56
Reputation: 1884
Please try the following pattern:
\('([^']+)'\)
The back-reference, $1, will be stripped out of apostrophes.
Working example @ regex101
To accomplish your second request, please use the following pattern:
'([^']+)'\s*(?=(?:\sand|\sor|\)))
Working example @ regex101
'words'
inside '()'
Upvotes: 2
Reputation: 67968
'(?=[^(]*\))
You can use lookahead
here.See demo.Replace by empty string
.
https://regex101.com/r/uE3cC4/28
Upvotes: 1