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.
鉴于前面的文本,我正在尝试获取属性的值。说我有这个:
<meta content="firsttag" name="datatoget" />
我想获得value名称(datatoget)。 我知道特定属性 ( <meta ... name=")之前的内容
value
<meta ... name="
我怎样才能使用正则表达式获得这个值?
我得到了content="firstag" name=".*",它将返回我想要的,但带有周围的文本。基本上我想要 `.* 部分。
content="firstag" name=".*"
(?<=name=")[a-zA-Z0-9]*
(?<=name=")确保文本 'name="' 在我们想要匹配的内容后面,而不将其包含在您的结果中。
(?<=name=")
[a-zA-Z0-9]限制捕获组,以便结束引号不包含在其中。
[a-zA-Z0-9]