At 10:28 AM +0530 5/27/11, vishesh kumar wrote:
Hi Jim
You should address all of your questions to the list as a whole. That
way you will get smarter people than me helping you.
echo $str | perl -pe 's/.*?(\d+\.[\d.]+).*/$1/'

Giving desired result, but i wonder what is use of ? in this expression
Did you try it without the question mark? If you do, you will see the
affect of "greedy" quantifiers. Without the question mark, the first
'.*' matches the longest string. This means that you won't get the
full IP address, just the minimal part at its rear end that matches
the '\d+\.[\d.]+' part, which could be '1.1' for example. With the
'?', the initial '.*' matches only the part of the string before the
first digit, and the whole IP address is matched and captured.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 8 | next ›
Discussion Overview
groupbeginners @
postedMay 24, '11 at 4:11a
activeMay 27, '11 at 12:26p



site design / logo © 2021 Grokbase