简体   繁体   中英

How to exclude group from deleting

i have this regex:

(%)([[:punct:]&[:alnum:]& ]{1,1})(%)

https://regex101.com/r/FUmP8G/1

and it's deleting whole 3 groups, how to keep 2nd group for searching but exclude it from deleting?

For example:

%@%

Result:

@

try this pattern /(?<=[%])([[:punct:]&[:alnum:]& ]{1,1})(?<![%])/

here a demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM