Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Help needed to get a regex to work

Apr
322
7
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
 
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
 
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
 
Back
Top
[FOX] Ultimate Translator
Translate