Page 1 of 1
getting partial find expressions into variables
Posted: 2007-07-17 00:48:54
With a selection containing an e-mail address, is it possible to get what is before and what is after the at sign into two variables?
Or to ask differently: If I do a find for that selection like
is it possible to get \1 and \2 into macro-variables with which to continue the macro?
Thanks for any help
Posted: 2007-07-17 01:36:35
Unfortunately there is no simple way to do this (as there is in Perl), but if you break into Perl you have several options. Probably the easiest is to simply have Perl repeat the regular expression:
Code: Select all
$expression = '(\S+)@(\S+)'
Find $expression, "E"
$found = Read Selection
$found1 = ''
$found2 = ''
$found =~ /$expression/;
$found1 = $1;
$found2 = $2;
Prompt "Found user '$found1' at domain '$found2'"
Posted: 2007-07-17 01:39:04
Oh, and I'll definitely file this as a feature request!
Posted: 2007-07-18 00:12:52
Yes. And in addition to the value, a pointer to the selection would be great. Or to expand on that idea further, the ability to return found objects as a list of selection offsets (or object references, as I would think of them) would open up great possibilities.