Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对正则表达式很陌生,我需要一些帮助。我试图弄清楚自己,但没有运气!
我正在尝试在 2 个字符串之间选择文本(最后一个字符串的字符)
IE:
word word2 :
我正在尝试在单词和之间选择“word2”:
谢谢!
另一种选择是使用这种模式
(?<=word\s).*(?=\s:)
参见Lookahead 和 Lookbehind 零宽度断言
/word (.*?) \:/这应该可以解决问题
/word (.*?) \:/
如果您获得第一组,这应该有效:
\w+\s*(.+)\s*: