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.
如果我有一个这样的字符串
<f = x1106f='0'>something
<> 中的值可以更改我将如何使用正则表达式来隔离“某物”并替换标签?
编辑:
<(.*?)> Pattern worked
你需要的是
string =~ />([^<]+)/
并将something被捕获$1。
something
$1
使用以下正则表达式捕获“某物”:
(?<=>)(.*?)(?=<)
假设在“某事”之后有一个结束标签。
链接到小提琴