in reply to Re^2: simple regexp problem
in thread simple regexp problem

This works too: /^(\w+?)(?:_(\w+))?$/ But why the last ? ? If I leave it off, it doesn't parse the string "AAAAAAA"

Thanks
Luca

Replies are listed 'Best First'.
Re^4: simple regexp problem
by ikegami (Patriarch) on Dec 06, 2005 at 15:31 UTC

    atom? (as opposed to atom??, atom*? and atom+?) means atom is optional. In other words, it provides the "optionally" in "you want AAAAAA optionally followed by _BBBBBB".