Re: How to spell out Roman numerals



           Thanks for the follow-up.  I am now looking at this closely due to an unexpected peculiarity in how the pattern matching in the NVDA dictionary works.  The not substituting for the single letter I will help quite a bit, as the rest of the roman numerals will work.  By the way, I just realized after typing out the rest of the message that the two entries for RN 5 and RN 10 should be entered in your dictionary BEFORE the one that covers all the other RNs due to the peculiarity I allude to.

            Because the pronoun I is now out of the picture, I will suggest that you use a variant on Luke's proposed regular expression for matching, as it eliminates a number of issues related to the peculiarity to which I make reference.  Since you have said you only need the Roman numerals one through ten, and we've now dropped one/the pronoun I, I am going to modify his regular expression only to accommodate that, and make it shorter for copy and paste.  Were you looking for any Roman numeral up to 9 "Roman digits" long, I wouldn't even consider touching it.  Give this a try as the pattern, and I can omit the colon part of matching now, too:


and this as the replacement:

\1 \2 \3 \4 \5

Oddly enough, the above will work for every Roman numeral between two and nine, except 5, because 5 is a single V followed by nothing, and also omits RN ten, because it's a single letter X, so you need two additional entries to cover those two.  Here's the pattern for RN 5:


and the replacement:

\1 \2

and for RN 10:


and the replacement:

\1 \2

All of the above presume the Roman numeral with possible optional letter afterward will be free-standing, that is, with whitespace (whether space, tab, newline, etc.) immediately before or after, at a word boundary.  Essentially they're their own "words."  If you know that you could have any specific punctuation coming immediately afterward, and know what specific punctuation marks are involved, I'd need to tweak to account for that.

Unless you're dealing with a text that includes Greek letter names written out, the above should not prove problematic.

Brian - Windows 10 Pro, 64-Bit, Version 2004, Build 19041  

It’s hard waking up and realizing it’s not always black and white.

     ~ Kelley Boorn


Join to automatically receive all group messages.