How to scrape, using LWP and a regex, the date argument to a javascript function?

那年仲夏 提交于 2019-12-01 23:00:14

Why do you have two whitespace characters in your pattern?

$content =~ s/.*dateFormat\('(\d{4}\/\d{2}\/\d{2}\s{2})'\);.*/$1/;
                                                 ^^^^^

they are not in your format example 'dateFormat('2012/02/07')'

I would say this is the reason why your pattern does not match.

Capture all dates

You can simply get all matches into an array like this

( my @Result ) = $content =~ /(?<=dateFormat\(')\d{4}\/\d{2}\/\d{2}(?='\))/g;

(?<=dateFormat\(') is a positive lookbehind assertion that ensures that there is dateFormat\(' before your date pattern (but this is not included in your match)

(?='\)) is a positive lookahead assertion that ensures that there is '\) after the pattern

The g modifier let your pattern search for all matches in the string.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!