in reply to Re: @ ergular expression
in thread @ ergular expression

Hi, I tried to implement what you have asked me to do but it;s printing nothing

The Part of code is as follows

#!/usr/bin/perl -w use strict; #The below variable $mystring is used for some other example my $mystring = "http://192.168.153.238/nightly_results/2009_12_02/log_ +lcla114.lss.emc.com_64___TestSuitePPAll_TestSuitePPSym_TestSuitePPper +f_TestSuitePPTx_TestSuitePPConCurrent_Prod_SymmSLV_AIX__3_15.html"; my $sample_sentence = "The kernel bitness: 64"; # ----------- The code corresponds to $mystring ------------# if($mystring =~ m/nightly_results(.*?)(.html)/) { my $web_link= "/nightly_db".$1; print $web_link; } if($mystring =~ m!([^/]+)$!){ my $file=$1; print "field= $file\n"; } #-----------Code ends corresponds to $myString -------------# #----------------- code corresponds to $sample_sentence -----------# print $sample_sentence =~ /kernel bitness:\s(\d*)/; #------------- COde ends here b--------------------#

I was trying to implement $mystring code in the case $sample_sentence as well.But I could not able to display the Appropriate output

Can you do one favor on me in order to extract the desired output ? Because the solution you asked me to implement is not working properly

Replies are listed 'Best First'.
Re^3: @ ergular expression
by kennethk (Abbot) on May 13, 2010 at 20:35 UTC
    This is why question content and formatting is so important: my expression was built for

    03:20:21 - PID: 11500 - kernel bitness: 64

    but the term you are trying to match is

    The kernel bitness:   64

    My expression failed because your real input contained more spaces. The following modified version matches the new provided input:

    print $str =~ /kernel bitness:\s*(\d*)/;

    By adding the * modifier to \s it will now match any amount of white space. Again, see perlretut for more info.

      Thanks a lot....