Thinking about my other problem, i decided I can\'t even create a regular expression that will match roman numerals (let alone a context-free grammar that will generate them
This works in Java and PCRE regex engines and should now work in the latest JavaScript but may not work in all contexts.
(?
The first part is the atrocious negative lookbehind. But, for logical purposes it is the easiest to understand. Basically, the first (? is saying don't match the middle
([MATCH])
if there are letters coming before the middle ([MATCH])
and the last (?!)
is saying don't match the middle ([MATCH])
if there are letters coming after it.
The middle ([MATCH])
is just the most commonly used regex for matching the sequence of Roman Numerals. But now, you don't want to match that if there are any letters around it.
See for yourself. https://regexr.com/4vce5