I am looking for a regex to replace all special characters except *
and \\*
. This regex snippet input.replaceAll('/[^a-zA-Z0-9*]*/', '')
converts all other characters except *
, But I am trying to ignore \\*
as well.
input.replaceAll('/[^a-zA-Z0-9*\\\\\\*]*/', '')
ignores \\*
but it also ignores \\
individually, I am trying to get an expression that considers \\*
as a combination and replaces rest.
Try this expression:
(?:(?!\\\*)(?!\*)(?![a-zA-Z0-9]).)+
See the demo here: https://regexr.com/50t1o
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.