in reply to Re: Parsing Issue while using Variable name in Pattern
in thread Parsing Issue while using Variable name in Pattern

Hi NetWallah,
Using \W worked perfectly fine. But I could not get the difference between \b and \W even though I was able to partially resolve the issue using \b. Using \b only worked for common strings in a machine name but not for machine names with special characters.

  • Comment on Re^2: Parsing Issue while using Variable name in Pattern

Replies are listed 'Best First'.
Re^3: Parsing Issue while using Variable name in Pattern
by NetWallah (Canon) on Feb 16, 2012 at 07:36 UTC
    From http://perldoc.perl.org/perlre.html#Regular-Expressions :
    \b Match a word boundary

    A word boundary (\b ) is a spot between two characters that has a \w on one side of it and a \W on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a \W .

    So, the "\b" will match "xxyy" if the following character is NOT [a-zA-Z0-9].

    However, if the terminating character in the match is NOT a "word" character, as in your case - the terminating character is ")", then the "\b" expects the NEXT character to be a "word".

    Hope this makes sense. If not, please experiment.

                “PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.”
            ― Jon Ribbens