Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

regex

Name: sage 2012-01-11 18:23

Is there a common regex notation for "at least one of each?"

For example, I want to specify that a string must contain "a", "b", and "c" in any order.  So these are all matched:


"abcabcabcbacbacb"
"acb"
"aaabbbccc"
"cba"
"cccbbbaaa"


but not "ab" or "aaaaaaaaaaaabbbbbbb".

Similarly, how about "exactly one of each" so that one_of_each("a" "b" "c") would match


abc
acb
bca


but not "aabc" or "aaaaa"?

Name: sage 2012-01-11 19:57

>>12
Well, I just mean, for example, that I use the * operator to mean "zero or more," the + operator to mean "one or more," etc... and I thought there might be a fairly common symbol for "one of each."

But it doesn't really matter.  I've decided to go with the & operator, like so:

a & b & c - matches "abc", "cba", "bca"...
+a & +b & +c - matches "abc", "cba", "abcabcacbacb"...

Name: Anonymous 2012-01-11 20:08

>>13
a|b|c is the usual one_of, but that matches a; b; c; ab; bc; bbbaacccc; cccbbbaaa; aaabbbccc; etc.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List