no problem:
jrereplace(s,"(mailto:)([EMAIL PROTECTED])",helper,'ALL');
the helper is a reference to a function, which takes 2 params, 1 is the full
matched string, 2 is an array of the portions to the matched string:
function helper(s,g) { return obfuscate(s); }
the jrereplace is defined as:
<cffunction name="JREReplace" access="public" returntype="string" output="false"
hint="This performs Java REReplaces on a string.">
<!--- Define arguments. --->
<cfargument name="Text" type="string" required="true" />
<cfargument name="Pattern" type="string" required="true" />
<cfargument name="Target" type="any" required="true" />
<cfargument name="Scope" type="string" required="false" default="ONE" />
<cfscript>
// Define the local scope.
var LOCAL = StructNew();
// Check to see if we are using a string replace or a method
// helper replace.
if (IsSimpleValue( ARGUMENTS.Target )){
// We are doing a standard string replace, so just
// use Java's string replacement. Check the scope.
if (NOT Compare( ARGUMENTS.Scope, "ALL" )){
// Replace all.
return(
CreateObject( "java", "java.lang.String" ).Init(
ARGUMENTS.Text
).ReplaceAll(
ARGUMENTS.Pattern, ARGUMENTS.Target
)
);
} else {
// Replace one.
return(
CreateObject( "java", "java.lang.String" ).Init(
ARGUMENTS.Text
).ReplaceFirst(
ARGUMENTS.Pattern,
ARGUMENTS.Target
)
);
}
} else {
// We are using a function here to replace out the
// groups. That means that matches have to be
// evaluated and replaced on an individual basis.
// Create the java pattern complied to the given regular
// expression.
LOCAL.Pattern = CreateObject(
"java",
"java.util.regex.Pattern"
).Compile(
ARGUMENTS.Pattern
);
// Create the java matcher based on the given text using the
// compiled regular expression.
LOCAL.Matcher = LOCAL.Pattern.Matcher( ARGUMENTS.Text );
// Create a string buffer to hold the results.
LOCAL.Results = CreateObject(
"java",
"java.lang.StringBuffer"
).Init();
// Loop over the matcher while we still have matches.
while ( LOCAL.Matcher.Find() ){
// We are going to build an array of matches.
LOCAL.Groups = ArrayNew( 1 );
for (
LOCAL.GroupIndex = 1 ;
LOCAL.GroupIndex LTE LOCAL.Matcher.GroupCount() ;
LOCAL.GroupIndex = (LOCAL.GroupIndex + 1)
){
// Add the current group to the array of groups.
ArrayAppend(
LOCAL.Groups,
LOCAL.Matcher.Group( JavaCast( "int", LOCAL.GroupIndex ) )
);
}
// Replace the current match. Be sure to get the value by
// using the helper function.
LOCAL.Matcher.AppendReplacement(
LOCAL.Results,
// Call the target function pointer using function notation.
ARGUMENTS.Target(
LOCAL.Matcher.Group(),
LOCAL.Groups
)
);
// Check to see if we need to break out of this.
if (NOT Compare( ARGUMENTS.Scope, "ONE" )){
break;
}
}
// Add what ever is left of the text.
LOCAL.Matcher.AppendTail( LOCAL.Results );
// Return the string buffer.
return( LOCAL.Results.ToString() );
}
</cfscript>
</cffunction>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:258835
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4