in reply to Re^2: Pattern matching fields with variable or NULL data
in thread Pattern matching fields with variable or NULL data

Hi ikegami,

Figured it out.

/\d{3}|\d\s\s|\d\d\s|\W{3}/

Thanks for your help.
  • Comment on Re^3: Pattern matching fields with variable or NULL data

Replies are listed 'Best First'.
Re^4: Pattern matching fields with variable or NULL data
by BrowserUk (Patriarch) on Oct 27, 2004 at 01:53 UTC

    That seems a bit over complicated.

    print $_, m[\s*(\d{0,3}\b)?] ? " contained '$1'" : ' contained nothing that matched' for '','1','1 ',' 1','12',' 12 ','123',' 123',' 123 ','1234','1 2 +3'; Use of uninitialized value in concatenation (.) or string at (eval 21) + line 1, <STDIN> line 19. contained '' 1 contained '1' 1 contained '1' 1 contained '1' 12 contained '12' 12 contained '12' 123 contained '123' 123 contained '123' 123 contained '123' 1234 contained '' 1 2 3 contained '1'

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^4: Pattern matching fields with variable or NULL data
by ikegami (Patriarch) on Oct 27, 2004 at 06:48 UTC

    That doesn't match "12 ", which you said should be matched.

    Also, \s should be used instead of \W (unless you want to match things like "!@#").