nunca he sido feliz con la expresión regular que coincida con funciones en la FQ Por lo tanto, escribí mi propia:
<cfscript>
function reFindNoSuck(string pattern, string data, numeric startPos = 1){
var sucky = refindNoCase(pattern, data, startPos, true);
var i = 0;
var awesome = [];
if (not isArray(sucky.len) or arrayLen(sucky.len) eq 0){return [];} //handle no match at all
for(i=1; i<= arrayLen(sucky.len); i++){
//if there's a match with pos 0 & length 0, that means the mime type was not specified
if (sucky.len[i] gt 0 && sucky.pos[i] gt 0){
//don't include the group that matches the entire pattern
var matchBody = mid(data, sucky.pos[i], sucky.len[i]);
if (matchBody neq arguments.data){
arrayAppend(awesome, matchBody);
}
}
}
return awesome;
}
</cfscript>
Aplicado a su problema, aquí está mi ejemplo:
<cfset origString = "joe smith <[email protected]>" />
<cfset regex = "<([^>]+)>" />
<cfset matches = reFindNoSuck(regex, origString) />
Dumping los "partidos" variable muestra que se trata de una matriz con 2 artículos. El primero será <[email protected]>
(porque coincide con la expresión regular completa) y el segundo será [email protected]
(porque coincide con el primer grupo definido en la expresión regular; todos los grupos subsiguientes también se capturarán e incluirán en la matriz).
¿Qué tal si nos dices lo que probaste y no funcionó? Es más fácil ir desde allí ... – jhwist