Magic Variables $&, $+ and $^N

Forum for TextAloud version 3

Moderator: Jim Bretti

Magic Variables $&, $+ and $^N

Postby PHenry1026 » Sun Jul 24, 2011 2:15 am

Greetings,

Do the magic variables

$& - text matched

$+ - text from the highest numbered $1, $2, etc.

$^N - text from the most recently closed $1, $2, etc.

work in the replacement line of TA3; if they do work can you give a simple example of one that works.

Percy Henry
PHenry1026
 
Posts: 238
Joined: Thu Jan 11, 2007 12:10 pm

Re: Magic Variables $&, $+ and $^N

Postby Jim Bretti » Tue Jul 26, 2011 6:59 pm

Hi Percy,

I don't see these anywhere in the documentation for the reg ex engine we use, and couldn't get anything like this to work with some experimenting. It looks like it is not supported.
Jim Bretti
NextUp.com
Listen and Learn Anywhere
http://www.NextUp.com
Jim Bretti
 
Posts: 1223
Joined: Wed Oct 29, 2003 11:07 am

Re: Magic Variables $&, $+ and $^N

Postby PHenry1026 » Tue Jul 26, 2011 7:35 pm

Greetings Jim,

Thanks for your reply.

Apart from the magic variable $1, $2, etc., are there any other $ magic variable(s) that you know of that is currently supported in TA3 (I recall you using a non-$[123...] variant , $0 - a copy of the script name, in one of your illustrative posts; see viewtopic.php?f=15&t=6073).

Thanks,

Percy Henry
PHenry1026
 
Posts: 238
Joined: Thu Jan 11, 2007 12:10 pm

Re: Magic Variables $&, $+ and $^N

Postby Jim Bretti » Wed Jul 27, 2011 9:43 am

Along with the usual $1, $2, etc, you can use these in the replacement string:

$0 - inserts the entire match
<SubStrName> - inserts a captured substring with the name 'SubStrName'.

An example of using <SubStrName> is something like this ... say you need to fix the pronunciation of numbers like $34.23 to read as 34 dollars and 23 cents. You could do it like this:

Regular Expression: \$(?<Dollars>\d+)\.(?<Cents>\d\d)
Pronounce as: $<Dollars> dollars and $<Cents> cents

instead of

Pronounce as: $1 dollars and $2 cents

Basically all this does is let you label the captured substrings so you don't need to rely on $1, $2 etc. It could make a complex expression easier to edit later, since the replacement string does not depend on $1 $2 $3 ordering.

Those are the only other substring replacement variables I know of ... if I run across anything like the ones you mentioned in the original post I'll post something here.
Jim Bretti
NextUp.com
Listen and Learn Anywhere
http://www.NextUp.com
Jim Bretti
 
Posts: 1223
Joined: Wed Oct 29, 2003 11:07 am

Re: Magic Variables $&, $+ and $^N

Postby PHenry1026 » Wed Jul 27, 2011 11:50 am

Thanks a lot Jim,

I am sure I will find <SubStrName> very useful.

Percy Henry
PHenry1026
 
Posts: 238
Joined: Thu Jan 11, 2007 12:10 pm


Return to TextAloud 3 Forum

Who is online

Users browsing this forum: No registered users and 2 guests