Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: printing LAST_MATCH_START/@- LAST_MATCH_END/@+ array where regex match begin/end

by perl_boy (Novice)
on Dec 29, 2021 at 00:57 UTC ( [id://11139996]=note: print w/replies, xml ) Need Help??


in reply to Re: printing LAST_MATCH_START/@- LAST_MATCH_END/@+ array where regex match begin/end
in thread printing LAST_MATCH_START/@- LAST_MATCH_END/@+ array where regex match begin/end

thank's for the tip. I have replaced the code inside the while loop with code you provided
open(F0, $ARGV[0]); while(<F0>) { my $match; while (/\t+/g) { $match = 1; print $-[0], ' ', $+[0], ' '; } print '-1 -1' unless $match; print "\n"; } close F0;
and works fine and get the expected results. good thank's :)))

However I find that that PerlDoc https://perldoc.perl.org/perlvar#Variables-related-to-regular-expressions
is a bit misleading when it says that indexes/positions before and after regex match can be found in the LAST_MATCH_START/@- and LAST_MATCH_END/@+ array by printing
print $+[0], " ",$+[1], " ", $+[2], "\n" ;

again thank's for the code :)))
  • Comment on Re^2: printing LAST_MATCH_START/@- LAST_MATCH_END/@+ array where regex match begin/end
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found