为什么此正则表达式断言不匹配? [英] Why this regex assertion doesn't match?

查看:157
本文介绍了为什么此正则表达式断言不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在html标签之间准备内容,我正在尝试这种简单的断言模式,但我不明白为什么它与该字符串不匹配.

I'm trying to just preg content between html tags, I'm trying this simple assertion pattern and I don't understand why it doesn't match this string.

<a href=http://url.com title="link">this is a ling</a>

(?<=<a.*>)([ \w]*)(?=<.*\/a>)

Debuggex演示

推荐答案

debuggex(PCRE,Javascript和Python)上的隐藏内容不能具有可变宽度,这意味着您可以使用固定宽度(3个字符)的(?<=<a>)但长度不能变化的东西(?<=<a.*>)(可以包含3个字符,也可以是4个或5个字符,等等).

Lookbehinds on debuggex (PCRE, Javascript and Python) cannot be of variable width, meaning that you can use (?<=<a>) which has a fixed width (3 characters) but not something that can vary in length (?<=<a.*>) (can have 3 characters, or 4, or 5, etc).

正则表达式完全无效,但是debuggex告诉您没有匹配项.

The regex simply is not valid but debuggex tells you that there is no match.

这篇关于为什么此正则表达式断言不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆