Help needed to get a regex to work

Apr 13, 2010
318
7
62
The Hague
From:
"(C)ontinue, (Q)uit current batch only or (A)bort all batch processing?"​

using perl syntax regex
\((\w{1})\)​

I want to extract "CQA"

echo %@REGEXSUB[%n,\((\w{1})\),"(C)ontinue (Q)uit current batch only or (A)bort all batch processing?"]​

shows "C" for n=1, but no results for higher values.

I'm lost.

Suggestions?

Cheers,
DJ
 
May 20, 2008
12,171
133
Syracuse, NY, USA
I'm not sure what is the intended behavior, and, depending on what it actually is, the help may be misleading. One interpretation is that the index (n) specifies which of your parenthesized expressions you want returned (and you specified only one parenthesized expression). This example would seem to indicate that:
Code:
v:\> echo %@REGEXSUB[1,\((.)\).*\((.)\),"(C) (Q) (A)"]
C
 
v:\> echo %@REGEXSUB[2,\((.)\).*\((.)\).*\((.)\),"(C) (Q) (A)"]
Q
 
v:\> echo %@REGEXSUB[3,\((.)\).*\((.)\).*\((.)\),"(C) (Q) (A)"]
A

I don't think TCC has anything built-in that will extract all three. If you use my 4UTILS plugin, perhaps @XREPLACE will help.
Code:
v:\> echo %@xreplace[.*\((.)\).*\((.)\).*\((.)\).*,\1\2\3,"(C)ont (Q)uit (A)bort"]
CQA
 
May 20, 2008
12,171
133
Syracuse, NY, USA
I misspoke. TCC has, built-in, @REREPLACE which works much like @XREPLACE.
Code:
v:\> echo %@rereplace[.*\((.)\).*\((.)\).*\((.)\).*,\1\2\3,"(C)ont (Q)uit (A)bort"]
CQA
 

Similar threads