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

Forum for TextAloud version 3

Moderator: Jim Bretti

Post Reply
Fret44
Posts: 16
Joined: Fri Mar 11, 2011 3:29 pm
Contact:

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

Post 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.
Jim Bretti
Posts: 1558
Joined: Wed Oct 29, 2003 11:07 am
Contact:

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

Post 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.
Jim Bretti
NextUp.com
Fret44
Posts: 16
Joined: Fri Mar 11, 2011 3:29 pm
Contact:

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

Post 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.
Post Reply