Need some help with a regular expression
How can I write an expression that filters everything between the delimiters (tab, comma, semicolon)? All the preceeding/trailing s开发者_如何学Gopaces must go as well.
Example input
Abra Cadabra ; Harry Potters,Magic Wand[tab]Sucks!
Matches
[Abra Cadabra]
[Harry Potters]
[Magic Wand]
[Sucks!]
Not desired
[Abra Cadabra ]
I came up with this to select everything BUT the output wanted
\s*[,;\t\n]\s*
Is there any way to "reverse" it?
As far as simple match/search goes, this one seems working:
[^,;\t ]+(?: +[^,;\t ]+)*
BTW, I agree with kevin's comment up there, I'd use something like
string.split(/\s*[,;\t]+\s*/)
You should be able to use this.
\s[^,;\t\n]*\s*
There is such a thing as a negated character class (you have to scroll down a bit). Try this:
[^,;\t\n]*
It works in Expresso, which is .NET-based.
Playing with that rubular thing, I think [^,;\t\n]*\b
may give you what you want...
精彩评论