Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 特定论坛的正则表达式_Regex - Fatal编程技术网

Regex 特定论坛的正则表达式

Regex 特定论坛的正则表达式,regex,Regex,我真的不知道如何使用正则表达式,我有一个任务,让批量图像下载程序找到一定数量的页面,例如页面1-20链接爬网 这是URL: /index.php?app=core&module=search&do=viewNewContent&period=month&userMode=&search_app=forums&sid=ceb2a9ba4039e4a06d3a6775aa735f2d&search_app_filters[forums][sea

我真的不知道如何使用正则表达式,我有一个任务,让批量图像下载程序找到一定数量的页面,例如页面1-20链接爬网

这是URL:

/index.php?app=core&module=search&do=viewNewContent&period=month&userMode=&search_app=forums&sid=ceb2a9ba4039e4a06d3a6775aa735f2d&search_app_filters[forums][searchInKey]=&st=400 
其页面(
st
param)以+25递增,因此以下页面为:

/index.php?app=core&module=search&do=viewNewContent&period=month&userMode=&search_app=forums&sid=ceb2a9ba4039e4a06d3a6775aa735f2d&search_app_filters[forums][searchInKey]=&st=425 

如何将页码与下一个连续页码进行匹配和替换?

您只需捕获最后的数字,然后使用您正在编写的任何语言将其增加25:

/(\/index\.php.+?)(\d+)$/
这将为您提供以$1表示的URL和以$2表示的页码或匹配项[2](但是您选择的语言代表第一个“捕获”)。有了它,你可以增加它

此Ruby示例将实现以下功能:

matches = url.match(/(\/index\.php.+?)(\d+)$/)
page = matches[2].to_i               # Convert the page number to integer
page = page + 25                     # Calculate the new page number
new_url = matches[1] + (page).to_s   # Merge in the new page number
对于这种URL格式,应该可以这样做