Ask a Question related to Macromedia ColdFusion, Design and Development.
-
Steve Grosz #1
Regular expression for both first and last name?
I'm new to regular expressions, can someone explain to me how I can
write one that will check for 2 names, at least, for a name field?
Thanks!
Steve
Steve Grosz Guest
-
Regular Expression
Hi, I am writing a script that parses an html file (which has been retrieved as a scalar by LWP::UserAgent). The script looks for everything in... -
Regular expression help
Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract... -
Regular expression bug?
All of CF's RE functions act in a weird way, contrary to the documentation (both CF's own, and the underlying Java Regex docs). The special... -
help on regular expression
Hi, I need some help on regular expression... i have following in variable $total_count $total_count = "##I USBP 000001 10:38:09(000)... -
[PHP] REGULAR EXPRESSION HELP
John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:... -
MikerRoo #2
Re: Regular expression for both first and last name?
The following code checks for and extracts two English/Irish names seperated by
whitespace and/or commas.
Cheers,
-- MikeR
<!--- Not sure if newsgroup readers can see attached code, so pasted twice.
--->
<CFSCRIPT>
sInput1 = " Billy ";
sInput2 = " O'Toole, Tommy ";
sNameFormat = "[a-z']+";
sNameSeperators = "[\s,]+";
if (0 NEQ REFindNoCase (sNameFormat & sNameSeperators & sNameFormat,
sInput2))
{
WriteOutput
(
'"#sInput2#" has the names ' &
REReplaceNoCase
(
sInput2,
"(#sNameFormat#)#sNameSeperators#(#sNameFormat #)",
'"\1" and "\2"'
)
);
}
</CFSCRIPT>
<CFSCRIPT>
sInput1 = " Billy ";
sInput2 = " O'Toole, Tommy ";
sNameFormat = "[a-z']+";
sNameSeperators = "[\s,]+";
if (0 NEQ REFindNoCase (sNameFormat & sNameSeperators & sNameFormat,
sInput2))
{
WriteOutput
(
'"#sInput2#" has the names ' &
REReplaceNoCase
(
sInput2,
"(#sNameFormat#)#sNameSeperators#(#sNameFormat #)",
'"\1" and "\2"'
)
);
}
</CFSCRIPT>
MikerRoo Guest



Reply With Quote

