Regular/匹配到字符为止:修订间差异
来自康健生活
< Regular
无编辑摘要 |
无编辑摘要 |
||
| (未显示同一用户的3个中间版本) | |||
| 第1行: | 第1行: | ||
== 示例 == | === 示例 1 === | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! 文本 ! 正则 | ! 文本 !! 正则 | ||
|- | |- | ||
| <pre>{{anchor|Language-specific}}</pre> || <syntaxhighlight lang="bash">^\{ | | <pre>{{anchor|Language-specific}}</pre> || <syntaxhighlight lang="bash">^\{+anchor\|(.*?\}+)</syntaxhighlight> | ||
|} | |} | ||
{{ | {{Double-columns|<syntaxhighlight lang="javascript"> | ||
'{{anchor|Language-specific}}'.match(new RegExp(/^\{ | '{{anchor|Language-specific}}'.match(new RegExp(/^\{+anchor\|(.*?\}+)/))</syntaxhighlight>|{{consoleout|<pre> | ||
['{{anchor|Language-specific}', 'Language-specific}', index: 0, input: '{{anchor|Language-specific}}', groups: undefined] | ['{{anchor|Language-specific}}', 'Language-specific}}', index: 0, input: '{{anchor|Language-specific}}', groups: undefined] | ||
</pre>}}}} | |||
=== 示例 2 === | |||
{| class="wikitable" | |||
|- | |||
! 文本 !! 正则 | |||
|- | |||
| <pre>payload@360.cn</pre> || <syntaxhighlight lang="bash">(.+)@(.+)</syntaxhighlight> | |||
|} | |||
{{Double-columns|<syntaxhighlight lang="javascript"> | |||
'payload@360.cn'.match(new RegExp(/(.+)@(.+)/))</syntaxhighlight>|{{consoleout|<pre> | |||
['payload@360.cn', 'payload', '360.cn', index: 0, input: 'payload@360.cn', groups: undefined] | |||
</pre>}}}} | </pre>}}}} | ||
2026年11月26日 (四) 05:02的最新版本
示例 1
| 文本 | 正则 |
|---|---|
{{anchor|Language-specific}} |
^\{+anchor\|(.*?\}+)
|
'{{anchor|Language-specific}}'.match(new RegExp(/^\{+anchor\|(.*?\}+)/))
['{{anchor|Language-specific}}', 'Language-specific}}', index: 0, input: '{{anchor|Language-specific}}', groups: undefined]
示例 2
| 文本 | 正则 |
|---|---|
payload@360.cn |
(.+)@(.+)
|
'payload@360.cn'.match(new RegExp(/(.+)@(.+)/))
['payload@360.cn', 'payload', '360.cn', index: 0, input: 'payload@360.cn', groups: undefined]
No categories