I'm trying to put together a Regex matching all but last occurrence of a specific character (say exclamation mark ! ), into a group, and then everything else into another group.
Examples:
a!1
a!!1
a!1!a!!a
It is safe to assume that the special character cannot be at the start, or the end of the string.
Ideally I want all this to be achieved in
Thanks, Stevo
(.*)\!(.*)
匹配的测试输入/输出在这里http://www.myregextester.com/index.php
this should catch anything before the last ! in a capturing group, and everything after in the other capturing group
(.*)!([^!]*)
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.