[英]Regex get last word of pattern
i have this string 我有这串
<p> this is some text</p>
can be any number of times 可以任意次数
to match i am using regex (?<=<p.*?>* )(.*)(?=</p>)
匹配我正在使用正则表达式
(?<=<p.*?>* )(.*)(?=</p>)
but i am getting this is some text
as output 但是我得到的
this is some text
作为输出
How to get this is some text
如何获得
this is some text
EDIT 编辑
i am sorry my string is <p class='randomstring'>a) this is some text</p>
in place of a)
there is digit some times. 很抱歉,我的字符串是
<p class='randomstring'>a) this is some text</p>
代替a)
<p class='randomstring'>a) this is some text</p>
,而不是a)
有时会有数字。
You can use this regex: 您可以使用此正则表达式:
(?<=<p[^>]*>)(?: )+(.*)(?=</p>)
And grab the captured group #1 for you match, that will be: 并抓住与您匹配的捕获的第一组 ,那就是:
this is some text
EDIT: Based on your edited question try this regex: 编辑:根据您编辑的问题,请尝试此正则表达式:
(?<=<p[^>]*>)[^)]*\) *(?: )+(.*)(?=</p>)
You could use the below regex which uses variable length positive lookbehind. 您可以使用下面的正则表达式,该正则表达式使用可变长度正向后看。
(?<=<p[^>]*>(?: )+)\b.*?(?=</p>)
This should match only the string this is some text
这应该只匹配字符串,
this is some text
Update: 更新:
(?<=<p[^>]*>\w*\)(?: )+)\b.*?(?=</p>)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.