faqts : Computers : Programming : Language processing : Compiler : Chomsky hierarchy : Regular languages : Regular expression

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 1 people (0%) answered Yes
Recently 0 of 1 people (0%) answered Yes

Entry

How to match a string with (whitespace at start) Roman numerals followed by a dot and anything more?

Oct 15th, 2003 07:26
Fred Jounters, http://nntp.x.perl.org/group/perl.fwp/2747


Since the question might be a bit short...
I've tried matching strings like
VII. Hello..
  II. sfs
So the rule could be: 
Match any line, that has(or has not) whitespace from the start on, 
followed by a roman numeral, and then by a dot and a whitespace, 
followed by anything else.
I've tried
$_ =~ /^(\s*?)(m?m?m?(c[md]|d?c{0,3})(x[lc]|l?x{0,3})(i[xv]|v?i{0,3}))
+(\.{1})(.*)$/
in Perl, which doens't do it...
Any ideas? Thanks!