in reply to Regular Expression Question
If multiple regexes are acceptable, this'll get you a little closer to what you want, I think. The first regex in the if statement matches the alphanumerics and commas, but not leading/trailing commas; the second regex excludes consecutive commas.
use warnings; use strict; while ( <DATA> ) { print "$1\n" if /^(\w+[\w,]+\w+)$/ && !/,,/; } __DATA__ !@#$as3dfa ,sdfas3df, asd3fsa,,a3sdf as3df,asdf3,3asdf,asd3f sad3fasdjasdfkasdfklas3jf 3sad3fasdjasdfkasdfklas3jf 3sad3fasdjasdfkasdfklas3jf3
Output is:
as3dfa sdfas3df as3df,asdf3,3asdf,asd3f sad3fasdjasdfkasdfklas3jf 3sad3fasdjasdfkasdfklas3jf 3sad3fasdjasdfkasdfklas3jf3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regular Expression Question
by TASdvlper (Monk) on Dec 04, 2003 at 20:06 UTC | |
by kesterkester (Hermit) on Dec 04, 2003 at 21:35 UTC | |
by kesterkester (Hermit) on Dec 04, 2003 at 21:41 UTC | |
|
Re: Re: Regular Expression Question
by Not_a_Number (Prior) on Dec 04, 2003 at 21:40 UTC |