Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello , I have this file containing the following :
export blblbb=R${oudfd}74ESE
now somtime it is exported to somthing like
export blblbb=erese
which is only a word , now is there a way to match the output for blblbb weather it contains only letters or mixed like R${oudfd}74ESE. for the second one I can do this :
if /^blblbb=(\w+)/ then I will get the whole thing erese which is good
for the second one
R${oudfd}74ESE if I do this if /^blblbb=(\w+)/ then I will only get R
so what is the way to match it if it is different . thanks

Title edit by tye

Replies are listed 'Best First'.
Re: matching not just words; alternative to (\w+) ?
by hardburn (Abbot) on Feb 05, 2004 at 18:57 UTC

    You can use the POSIX character set graph to do this:

    /\A blblbb=([[:graph:]]+)/x

    graph matches pretty much anything printable except whitespace. Note that the double square brackets are required.

    ----
    I wanted to explore how Perl's closures can be
    manipulated, and ended up creating an object
    system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Re: matching
by borisz (Canon) on Feb 05, 2004 at 18:23 UTC
Re: matching
by duff (Parson) on Feb 05, 2004 at 18:09 UTC

    Perhaps .+ or \S+ is what you want instead of \w+?

      Both of those will also match control characters, like ESC and NUL. Probably a bad idea.

      ----
      I wanted to explore how Perl's closures can be
      manipulated, and ended up creating an object
      system by accident.
      -- Schemer

      : () { :|:& };:

      Note: All code is untested, unless otherwise stated

Re: matching
by NetWallah (Canon) on Feb 05, 2004 at 18:33 UTC
    Anonymous Monk probably does not want the whitespace in the match, so (.+) is probably not appropriate. (\s+) {Lower-case s} matches whitespace, so it will not work. Try
    if /^blblbb=(\S+)/

    "When you are faced with a dilemma, might as well make dilemmanade. "