Не съм съвсем сигурен как работи / какво означава това ...
my ($value) = ($out =~ /currentvalue[^>]*>([^<]+)/);
Така че основно това е част от CURL / PERL скрипт, той отива на www.example.com и намира <span id="currentvalue"> GETS THIS VALUE </span>
в страниците html.
Какво точно прави [^>]*>([^<]+)/)
част от скрипта ли? Определя ли, че търси span id = ".."?
Къде мога да науча повече за функциите [^>] *> ([^ <] +) /)?
Отговори:
8 за отговор № 1/.../
известен още като 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
----------------------------------------------------------------------
7 за отговор № 2
Това е обикновена проба на Perl. Виж това настойнически
/ # 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