Peter is right.  Now that I see what you're trying to do, I don't
think it can be done in CF.  I'm don't think it can be done in Java,
either.  To perform multiple actions within a single string (which
you're doing since you're assuming multiple matches), you'll need to
use REFind() and loop over each match.

<cfscript>
s      = yourString;
start = 1;
re     = 'mailto:[EMAIL PROTECTED]';

while ( start lt len ( s ) ) {
     curMatch = REFindNoCase ( re, str, start, true );

     if ( curMatch.pos[1] neq 0 ) {
          /**
           * call obfuscate() on each match
           *
           */
     }
     start = curMatch.pos[1] + curMatch.len[1];
</cfscript>

And, while I'm here, you're mailto string is missing a few valid
characters in email addresses.  Most commonly, the "-", but others are
also valid - if rarely used.  If you're interested in RFC-compliance
then use [_A-Za-z0-9!##$%&'*+/=?^`{|}~-]+ instead of [\w.]+.

Looks weird, I know, but the RFC says those characters are all legal
in an email address and I've got customers who have "&" in their
addresses.  That's how I found out that the characters are legal (I'm
not prone to perusing RFCs just for grins).  :-)

On 11/2/06, Ryan Mitchell <[EMAIL PROTECTED]> wrote:
> ok, so i have a long string with emails within it, what i want to do is 
> identify the emails in teh string, and replace them with the result of the 
> function obfuscate(email)...
>
> so what im doing is this:
>
>         function hideEmails(s) {
>                 return rereplace(s,"(mailto:)([EMAIL 
> PROTECTED])",obfuscate("\1\2"),'ALL');
>         }
>
> however, all this does is return an encrypted version of the string "\1\2", 
> instead of the backreferences.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258827
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to