RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Roman numerials
Expression
^(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))$
Description
This RE validates alpha characters that evaluate to Roman numerials, ranging from 1(I) - 3999(MMMCMXCIX). Not case sensitive.
Matches
III | xiv | MCMXCIX
Non-Matches
iiV | MCCM | XXXX
Author Rating: Not yet rated. Michael Ash
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: http://www.kobe7playoff.com/
Name: kobe 7
Date: 5/18/2012 2:09:21 AM
Comment:
http://www.kobe7playoff.com/ http://www.kobe7playoff.com/nike-lebron-9ix-c-24.html http://www.kobe7playoff.com/dwyane-wade-shoes-c-15.html


Title: http://www.myairmax2012shoesoutlet.com/
Name: nike air max mens
Date: 5/17/2012 11:56:55 PM
Comment:
http://www.myairmax2012shoesoutlet.com/ http://www.myairmax2012shoesoutlet.com/nike-air-max-2012-c-1.html http://www.myairmax2012shoesoutlet.com/nike-air-max-2011-c-4.html


Title: http://www.roseshoesoutlet2012.com
Name: Adizero Rose 1.0
Date: 5/17/2012 11:46:49 PM
Comment:
http://www.roseshoesoutlet2012.com http://www.roseshoesoutlet2012.com/adidas-adizero-rose-10-c-2.html http://www.roseshoesoutlet2012.com/adizero-crazy-light-c-3.html


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.


Copyright © 2001-2014, RegexAdvice.com | ASP.NET Tutorials