On 20 December 2011 13:45, Saravanan Murugaiah <saravanan.muruga...@gmail.com> wrote: > Dear All,
Hello > I am a learner in Perl and this is my first post in this group. I need to > search a word "Test 1.2.1" in my file. I am using "$_ =~m/Test \d+", but it > searched only "Test 1" not the full content. I need to check whether it is > "Test 1" or "Test 1.2" or "Test 1.2.1". Kindly help me in this regard Your search expression says match the work 'Test' then some literal whitespace the any number of digits. But you have not accounted for the periods/dots/full stops. I think an regular expression like this would help. /test\s+\d+(?=\.\d+)*/i /s+ matches whitespace including tabs ?= means look ahead from the match just found EG: 'Test 1' and see if you can find a literal . followed by one or more digits. The * mean zero or more times. the i flags means make the search case-insensitive. Have a look at perldoc perlretut (http://perldoc.perl.org/perlretut.html) for more tips. Good luck, Dermot. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/