Re: Pronunciation of phone numbers

George McCoy


This regex works for phone numbers formatted with dashes, with or without parentheses, but fails when it encounters spaces.

If I replace the dashes in the pattern string with spaces, it works with spaces, but, of course, not with dashes.


On 9/25/2020 10:25 PM, Brian Vogel wrote:

         If you use either of the formats I previously mentioned, whether or not the area code is enclosed in parentheses or not, you can use the instructions that follow.  I am going to give the regular expression (regex) you will want to use first and the replacement string right afterward before giving the step-by-step instructions that would be used to do this for any regular expression and replacement.  You begin copying the regex with the opening open parenthesis and stop at the end of the line.  For the replacement, if you do not want NVDA to say, "area code," before the first three digits then you can omit those two words and start copying at the opening backslash until the end of the line.

regex: \(?(\d)(\d)(\d)\)?[ -](\d)(\d)(\d)-(\d)(\d)(\d)(\d)
replacement: area code \1 \2 \3 \4 \5 \6 \7 \8 \9 \10
Adding a Regular Expression match to the Default Dictionary
1. Hit NVDA+N,P,D,D   NVDA Main Menu, Preferences, Speech dictionaries, Default Dictionary
2. Hit ALT+A to activate the Add Button or navigate to it and activate it.
3. In the dialog that appears, paste or enter a regular expression in the Pattern edit box.
4. Paste or enter the replacement you want to hear in the Replacement edit box.  If you're using a capturing regular expression this may be a sequence of backslashes followed by the numbers of the capture groups you're using.
5. The Comment edit box should either have a comment that helps you to remember the purpose of this dictionary entry, which is preferable, or be left blank.
6. Leave the Case Sensitive checkbox unchecked.
7. The Type radio button should be set to Regular Expression.
8. Activate the OK button


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.