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.
我正在尝试在></. 下面的示例我想要“文本”
></
>text</
但我不能这样做。尝试了以下,但它不喜欢正则表达式末尾的斜线
\>(.*?)\<\
我正在尝试在 TextPad 中执行此操作。这应该怎么做?我最终想删除这两个字符之间的所有文本,所以我剩下的就是:<element></element>
<element></element>
你很接近..使用以下内容:
(>).*?(<\/)
并替换为\1\2
\1\2
见演示
或者
您可以使用lookbehind 和lookaheads:
(?<=>)(.*?)(?=<\/)
并替换为''(空字符串)
''
RegEx 明智的做法是,您可以使用 3 个分组,而替换只使用第一组和第三组:\1\3。
Find: (>)(.*)(</) Replace: \1\3
尝试做:
\>(.*?)\<\/
您正在尝试的正则表达式实际上会给出错误,因为\在那之后您没有任何东西。
\