A quick brown regex, please ...

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default A quick brown regex, please ...

    Need to strip "-", "/" and any number of commas after the las character of the string.
    This /[\,\/-]/g, "" almost does it, but it strips "all" of the commas. Thanks in advance.
    ContiW
    Conti Guest

  2. Similar Questions and Discussions

    1. XML Quick help
      I am working on a simple flash interface, ussing the tutorial below. http://www.macromediahelp.com/flash/simple_flash_and_xml_sample/ It is all...
    2. Looking for Colors Brown and Blue
      I am trying to find the color Brown and Blue. Illustrator gives me orange and red, but not brown or blue.
    3. Brown popups offering to give programs to block popups
      are these genuine ads to protect windows xp owners or are they spyware ads. as they all sem to want to stop popups, but the most popups i get...
    4. Quick Q about $|
      Hi, What does: $|=1; select(STDOUT); do? I understand that STDOUT is selected as the default handle, but what about the bit preceding it?...
  3. #2

    Default Re: A quick brown regex, please ...

    Hmm, sounds like a cracker. I don't know much about RegEx, but one of my guiding
    instincts is, whenever the problem contains the word "and" , I look for a
    stepwise answer.
    For example, here, I would first strip out "/" and "-". Then, in the next
    step, I would strip out
    the commas at the end.

    <cfset s="Need - to strip -, / and any num/ber of commas, after the, last
    char-acter, of the string.,,,,,">
    <strong>original string:</strong> <cfoutput>#s#</cfoutput><br>
    <!--- Step 1 --->
    <cfset t = REReplace(s,"[\/-]","","all")>
    <strong>"/" and "-" removed:</strong> <cfoutput>#t#</cfoutput><br>
    <!--- Step 2 --->
    <strong>Trailing commas removed:</strong>
    <cfoutput>#REReplace(t,",+$","","all")#</cfoutput>


    BKBK Guest

  4. #3

    Default Re: A quick brown regex, please ...

    Thanks very much BKBK. I didn't mention that it was for a JavaScript function.
    My fault. And I cannot think about performing the commas replacement with
    ColdFusion as the followinf step is using the string in
    "FCKConfig.ToolbarSets[userToolbar].innerHTML = regexedString". Thanks anyhow.
    Appreciate.
    WalterConti

    Conti Guest

  5. #4

    Default Re: A quick brown regex, please ...

    Thanks very much BKBK. I didn't mention that it was for a JavaScript function.
    My fault. And I cannot think about performing the commas replacement with
    ColdFusion as the followinf step is using the string in
    "FCKConfig.ToolbarSets[userToolbar].innerHTML = regexedString". Thanks anyhow.
    Appreciate.
    WalterConti

    Conti Guest

  6. #5

    Default Re: A quick brown regex, please ...

    <script language="JavaScript">
    s="Need - to strip -, / and any num/ber of commas, after the, last char-acter,
    of the string.,,,,,";
    alert(s);
    re1=/[\/-]/g;
    re2=/,+$/;
    t1 = s.replace(re1,"");
    alert("/ and - removed: "+t1);
    t2 = t1.replace(re2,"");
    alert("trailing commas removed: "+t2);
    </script>

    BKBK Guest

  7. #6

    Default Re: A quick brown regex, please ...

    Wow, I swear I didn't do the multiple send!
    Thank you BKBK. Cheers for the feedback!
    WalterConti
    Conti 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