NYCPHP Meetup

NYPHP.org

[nycphp-talk] Regular expression in PHP with preg_match using Roman Numerals?

David Roth davidalanroth at gmail.com
Sat Feb 20 23:22:37 EST 2010


Hi Folks.

I didn't come up with this method, I'm just the one who has to deal  
with it. :-)

The year is represented most of the time in this format:

(2000)

This regular expression in preg_match to extract it has been working  
fine:
	preg_match('/\((19|20)[0-9][0-9]\)/',$line,$found);

However, other times it is represented with Roman Numeral version  
control when there is more than one version:

(2000/I)
or
(2000/II)

So far it looks like the version control goes out to three Roman  
Numbers. Like I said, I didn't come up with this.

It would be just peachy if some kind person here could show me an  
elegant way to handle this in PHP (as a regular expression?) which  
might  be, for example, either (2000) or (2000/V). Thanks in advance!

David Roth





More information about the talk mailing list