简体   繁体   中英

Regex: How to search in reverse, obtaining all characters up to a specific character?

Say I have wordsandnumbers!morestuff!morelettersandnumbers , I want to get everything after the last ! (meaning there may be more than 2 ! ). How can I do this using regex?

您可以使用$将正则表达式匹配项锚定到字符串的末尾,然后使用所有连续的非感叹号(直到该点为止):

[^!]*$

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