亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 正則表達式怎么用。。 [打印本頁]

作者: pandaiam    時間: 2018-08-03 12:43
標(biāo)題: 正則表達式怎么用。。
現(xiàn)在有這個字符串
jakee and zz done.<p>zzz</p> <p style=\"text-align: center;\" align=\"justify\">==TUIGUANG===</p>\n<p align=\"justify\"><img style=\"width: auto;\" src=\"https://imag.xxxx.com/b931035c-5bf2-4553-9593-07480f74a5c6.png\" /></p> this should not dispeared <p>ALL MY ...</p> <p > See you</p> behan


現(xiàn)在用
  1. regexp.MustCompile(`<p.*?TUIGUANG.*?</p>`)
復(fù)制代碼

匹配,愿意是想匹配到
<p style=\"text-align: center;\" align=\"justify\">==TUIGUANG===</p>
結(jié)果是直接匹配到了
<p>zzz</p> <p style=\"text-align: center;\" align=\"justify\">==TUIGUANG===</p>
有什么寫法可以只匹配到最短的那段嗎。。

我不知道別的正則是不是支持這種匹配,引用程序是用go寫的,就先關(guān)注go的regexp了。

謝謝。



作者: lxyscls    時間: 2018-08-08 10:51
回復(fù) 1# pandaiam
...
作者: lxyscls    時間: 2018-08-08 10:51
本帖最后由 lxyscls 于 2018-08-08 10:53 編輯

回復(fù) 1# pandaiam
In [11]: r = re.search('<p\ .*?TUIGUANG.*?</p>', 'jakee and zz done.<p>zzz</p> <p style=\"text-align: center;\" align=\"justify\">==TUIGUANG===</p>\n<p align=\"justify\"><img style=\"width: auto;\" src=\"https://imag.xxxx.com/b931035c-5bf2-4553-9593-07480f74a5c6.png\" /></p> this should not dispeared <p>ALL MY ...</p> <p > See you</p> behan')

In [12]: r.group()
Out[12]: '<p style="text-align: center;" align="justify">==TUIGUANG===</p>'

python







歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2