in reply to regex question

The non-greedy *? is perfectly happy to eat up nothing unless you tell it how far to go. So either use the greedy version for the second capture or anchor with, say, $. Try either of these:

print "$1 $2\n" if($str=~/(.*?)\*(.*)/);

print "$1 $2\n" if($str=~/(.*?)\*(.*?)$/);
Note that both of them produce:
Test .Value
Elimination of that . left as an exercise. ;-)

Replies are listed 'Best First'.
Re^2: regex question
by Alien (Monk) on Sep 01, 2008 at 07:45 UTC
    Thanks for your replies ! I am grateful !