Re: How to spell out Roman numerals


Luke Davis
 

An alternative to Brian's method, might be something longish like the following. Although again I don't fully understand the issue, not having gotten Janet's messages, so it might fail the use case after all.

I spent about an hour trying to figure out some more elegant way of doing this, and couldn't come up with anything shorter than the below. Brian's method is probably easier to understand, although this cuts and pastes as a single entry, so i guess it has that going for it. :)

The idea below is to match, at the start of any word, any RN between one and nine characters long, and additionally to match one optional subsequent non RN character, and a required final colon. That was what I understood from Brian's messages anyway.

Match type: regular expression
Case sensitive: yes
Pattern:

\b([MCLXVI])([MCLXVI])?([MCLXVI])?([MCLXVI])?([MCLXVI])?([MCLXVI])?([MCLXVI])?([MCLXVI])?([MCLXVI])?([a-zA-Z])?(?=:)

Replacement:

\1 \2 \3 \4 \5 \6 \7 \8 \9 \10

I tested a version of this in a temporary dictionary, and it appeared to work.

The weird construct for the colon at the end, is because it's punctuation. I don't know when NVDA applies punctuation processing to this chain of dictionaries, and so I thought it better to make sure the colon was there, but let it actually be processed by normal rules with a forward reference. I did not test that part in the temp dictionary, as I only just thought of it. If this fails, try replacing "(?=:)" with just ":", and put a colon at the end of the replacement string as well.

Luke

Join nvda@nvda.groups.io to automatically receive all group messages.