Title: Update
Name: Michael Ash
Date: 11/10/2004 1:32:52 PM
Comment:
Updated from
^(?i:M{0,3}((C[DM])|(D?C{0,3}))?L?(X((X{1,2})|L|C)?)?((I((I{1,2})|V|X|L)?)|(V?I{0,3}))?)$
which allowed a few bad matches
Title: Re:Combination of letters
Name: Michael Ash
Date: 1/27/2004 2:05:33 PM
Comment:
Better late than never.
When I was first asked about doing this I couldn't see how it could be done easily but now I've come up with a solution to this question,
http://www.regexlib.com/REDetails.aspx?regexp_id=564
Title: Update
Name: Michael Ash
Date: 12/9/2003 11:18:56 PM
Comment:
I've updated this RE a bit. Still works the same just a shorter expression.
Here's the original
^(?:[mM]{1,3})?(?:(?:[cC][dDmM])|(?:[dD]?(?:[cC]{1,3})?))?[lL]?(([xX])(?:\2{1,2}|[lL]|[cC])?)?((([iI])((\5{1,2})|[vV]|[xX]|[lL])?)|([vV]?([iI]{1,3})?))?$
Title: Re:Combination of letters
Name: Michael Ash
Date: 10/20/2003 12:18:40 PM
Comment:
No backreferences won't work here because you have too many variations.
Your attempted expression doesn't work because the square braces [], basically says choose one of the things inside.
Also it doesn't capture the match which is what you need for a backreference.
But even if it did and you said next match something not the same as the first subexpression [^\1],
that could be anything except the first character you matched.
So AZ, A1 as well as AB would match that type of logic equally.
The backreference would have no knowledge of your original set of choices.
Title: Re:Combination of letters
Name: Peter Ionescu
Date: 10/18/2003 11:14:19 PM
Comment:
Can you not use backreferences? I'm not quite familiar with RE, but can you not capture the first letter [ABCD] and then express next one as "not in first capture" and next one "not in first and second capture" and so on...
I don't know how to write this, I tried something like ^[ABCD][^\1][^\1\2][^\1\2\3]$ and of course it didn't work:-( Sorry for my ignorance...
Title: Re:Combination of letters
Name: Michael Ash
Date: 10/17/2003 3:29:16 PM
Comment:
Only to validate every combination. Which would likely be a long an ugly thing to read.
This RE A((B(CD|DC))|(C(BD|DB))|(D(BC|CB))) would validate all the occurences that started with the letter "A".
You'd have to append an almost duplicate expression for "B", "C", "D"
and OR them all together (Acombo|Bcombo|Ccombo|Dcombo).
If you changed the A to a "B",
and the original B's to A's you'd have all the combos starting with B
Title: Combination of letters
Name: Peter Ionescu
Date: 10/17/2003 11:42:33 AM
Comment:
Do you have any idea on how to validate a string consisting of single occurences of letters A,B,C,D.
E.g. ABCD, BDCA, CADB, etc.
Thanks.