Page 1 of 1

Regex to pronounce words like [T]he or [w]hen correctly?

Posted: Fri Sep 07, 2012 1:04 pm
by Fret44
I've been trying to come up with regex that will identify words with bracket first letters and pronounce them correctly. I find this often in cases where people are capitalizing the first letter of quoted material.

Examples: [T]oday, [Y]esterday, lue, [g]reen

Is there a way for Textaloud to identify words with bracketed first letters like that and read them as if the brackets did not exist?

If there is it would seem to be beyond my regex skills. Or maybe I'm just missing something.

If you can offer some help, I'd really appreciate it.

Re: Regex to pronounce words like [T]he or [w]hen correctly?

Posted: Mon Sep 10, 2012 6:00 pm
by Jim Bretti
You could try starting off with a regular expression like this:

Code: Select all

(\[)([a-z])(\])(\w{2,})
Then for Pronounce As, use $2$4

There are four parentheses pairs, the first pair matches the character '[', the second pair matches any letter, the third pair matches ']', and the last pair matches 2 or more letters. So the expression is looking for a bracketed letter followed by two or more letters. Using $2$4 for 'pronounce as' grabs pair numbers 2 and 4, and excludes the brackets.

You can adjust if you need to, just post here if you need help. Be sure to leave the case sensitive checkbox unselected.

Re: Regex to pronounce words like [T]he or [w]hen correctly?

Posted: Mon Sep 10, 2012 10:22 pm
by Fret44
Thank you so much!

I'm going to have to sit down and figure out exactly how and why that works.

But initial testing says it does, indeed, work. I'll let you know if I run into any problems or need any further help understanding it.