我不确定这是如何工作的/这意味着什么......
my ($value) = ($out =~ /currentvalue[^>]*>([^<]+)/);
Run Code Online (Sandbox Code Playgroud)
所以基本上,这是CURL/PERL脚本的一部分,它进入www.example.com,并<span id="currentvalue"> GETS THIS VALUE </span>
在页面html中找到.
[^>]*>([^<]+)/)脚本的一部分究竟是做什么的?它是否定义了它寻找span id =".."?
我在哪里可以了解更多关于[^>]*>([^ <] +)/)函数的信息?
/.../aka m/.../是匹配运算符.它检查其操作数(在LHS上=~)是否与文字中的正则表达式匹配.运算符记录在perlop中.(转到"m/PATTERN /".)正则表达式记录在perlre中.
至于这里使用的正则表达式,
$ perl -MYAPE::Regex::Explain \
-e'print YAPE::Regex::Explain->new($ARGV[0])->explain' \
'currentvalue[^>]*>([^<]+)'
The regular expression:
(?-imsx:currentvalue[^>]*>([^<]+))
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
currentvalue 'currentvalue'
----------------------------------------------------------------------
[^>]* any character except: '>' (0 or more times
(matching the most amount possible))
----------------------------------------------------------------------
> '>'
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
[^<]+ any character except: '<' (1 or more
times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
这是普通的Perilla regexp.请参阅本教程
/ # Start of regexp
currentvalue # Matches the string 'currentvalue'
[^>]* # Matches 0 or more characters which is not '>'
> # Matches >
( # Captures match enclosed in () to Perl built-in variable $1
[^<]+ # Matches 1 or more characters which is not '<'
) # End of group $1
/ # End of regexp
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
263 次 |
| 最近记录: |