Hello i am using perl and now i don’t know how to get ouput like i want. I want only print all digit beetween DIGIT below is my code i hope somebody here can help me to find a right regex.
Please help me … here my code
#!/usr/bin/perl
my $string = "<TR><TD COLSPAN=2 VALIGN=TOP>Please enter the random key shown below:<TR><TD> <TD VALIGN=TOP><FONT SIZE=+1><FONT COLOR=WHITE>...</FONT>4<FONT COLOR=WHITE>...</FONT>5<FONT COLOR=WHITE>...</FONT>4<FONT COLOR=WHITE>..</FONT>4<FONT COLOR=WHITE>..</FONT>2<FONT COLOR=WHITE>..</FONT>2</FONT></TR>";
if ($string =~ m,</FONT>(\d)<FONT COLOR=WHITE,i) {
print "$1\n"; #output 454422
} else {
print "Wrong Regex! \n";
}
You’re looking for the
/gflag for “global match”, which matches all occurrences of the pattern, as opposed to just the first one.Note that the last
2won’t match your pattern. It would if you changed it to: