in reply to simple regexp problem
Square brackets don't mean what you think they mean. Use (?:...) to group things without capturing, and use the ? suffix to make something optional.
/^(\w+)(?:_(\w+))?$/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: simple regexp problem
by ikegami (Patriarch) on Dec 05, 2005 at 17:46 UTC | |
by jeanluca (Deacon) on Dec 06, 2005 at 13:36 UTC | |
by ikegami (Patriarch) on Dec 06, 2005 at 15:31 UTC |