Regular expression for both first and last name?

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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)...
    5. [PHP] REGULAR EXPRESSION HELP
      John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139