KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why doesn't the first print statement output what I expect: first = This is a test string, sec = This is a test string Since both * and + are greedy, why does the the inner * i.e. inside the "((" in the first match not consuming the entire string? use strict; use warnings; my $string = "This is a test string"; $string =~ /((.*)*)/; print "first = $1, sec = $2\n"; #prints "first = This is a test string, sec =" $string =~ /((.+)*)/; print "first = $1, sec = $2\n"; #prints "first = This is a test string, sec = This is a test string"
Tags (comma-separated)
Save Edits
Cancel