我在试着匹配一个模式:
show_clipping.php?CLIP_id=*发自:
a href="javascript:void(0);" onclick="MM_openBrWindow('show_clipping.php?CLIP_id=575','news','scrollbars=yes,resizable=yes,width=500,height=400,left=100,top=60')">some text</a>哪里
*只能是数值(例如: 0,1,1234)
结果必须返回全部内容(show_clipping.php?CLIP_id=575)
我试过的是:
show_clipping.php\?CLIP_id=([1-9]|[1-9][0-9]|[1-9][0-9][0-9])但是,我的尝试会将其余的数字从575截断,结果如下:
show_clipping.php?CLIP_id=5发布于 2012-12-01 11:10:07
您没有指定您正在使用的语言,所以下面是regex
'([^']+)'解释
' # Match a single quote
([^`])+ # Capture anything not a single quote
' # Match the closing single quote 基本上,它用单引号捕获所有内容,show_clipping.php?CLIP_id=5是第一个捕获组。
看到它的动作这里。
为了只捕获show_clipping.php?CLIP_id=5,我会做'(.*CLIP_id=[0-9]+)'
' # Match a single quote
(.* # Start capture group, match anyting
CLIP_id= # Match the literal string
[0-9]+) # Match one of more digit and close capture group
' # Match the closing single quote发布于 2012-12-01 11:15:30
答:^(0=1-9*)$回答前:数值的Regex模式
(答覆第6号)
发布于 2012-12-01 11:32:27
那这个呢?
onclick.match(/show_clipping\.php\?CLIP_id=\d+/)
["show_clipping.php?CLIP_id=575"](从您问题的标记来看,我假设您使用的是JavaScript)
https://stackoverflow.com/questions/13658804
复制相似问题