<cfscript>
regexp = "##[[:space:]]*([0-9]{2-3})";
stTmp = REFindNoCase(regexp,str,1,true);
if(stTmp.pos[1])
result = Mid(str,stTmp.pos[2],stTmp.len[2]);
else
result = "";
</cfscript>

If you need to find all, you do it in a loop:

<cfscript>
regexp = "##[[:space:]]*([0-9]{2-3})";
results = ArrayNew(1);
start = 1;
while(true){
stTmp = REFindNoCase(regexp,str,start,true);
if(stTmp.pos[1]){
ArrayAppend(results,Mid(str,stTmp.pos[2],stTmp.len[2]));
start = stTmp.pos[1] + stTmp.len[1];
}
else break;
}
</cfscript>

Probably you want to make sure that the character after the 2-3 digits
is not a digit. If so, modify the regexp to
regexp = "##[[:space:]]*([0-9]{2-3})([^0-9]|$)";

On CFMX you could use negative lookahead:
regexp = "##\s*(\d{2,3})(?!\d)";

Pascal

> -----Original Message-----
> From: Andy Ousterhout [mailto:[EMAIL PROTECTED]
> Sent: dinsdag 17 februari 2004 0:05
> To: CF-Talk
> Subject: Regular _expression_ help
>
> What regular _expression_ would find a "#" followed by any
> number of blanks, followed by 2-3 numbers
>
> For example, I want to return 45 from this string:
>
> Testing this string # 45 to 46
>
> Andy
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to