Regular Expression - Need Help

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Regular Expression - Need Help

    Hi,

    I have the following:
    <cfset input ="
    Origin: cohnok-530a
    (190.068.59.250)
    Type: Log
    Action: Accept
    Service: nagios-nsc
    lient (1248)">

    For the line that starts with Service. I want it to be one continous line
    Service: nagios-nsclient (1248)

    I've tried the code below, but it is not doing the trick.
    <cfset input = REreplace (input, "[[:cntrl:]]"," ","ALL")>

    Any Advice on how to make this work would be greatly appreciated.

    Thanks

    Andy






    _andyK 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 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!...
    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 - Need Help

    try to use back referencing in the regular expression.
    CF_fdk Guest

  4. #3

    Default Re: Regular Expression - Need Help

    Can't seem to figure out how to get that to work
    _andyK Guest

  5. #4

    Default Re: Regular Expression - Need Help

    On Thu, 19 May 2005 16:46:16 +0000 (UTC), _andyK wrote:
    > Hi,
    >
    > I have the following:
    > <cfset input ="
    > Origin: cohnok-530a
    > (190.068.59.250)
    > Type: Log
    > Action: Accept
    > Service: nagios-nsc
    > lient (1248)">
    >
    > For the line that starts with Service. I want it to be one continous line
    > Service: nagios-nsclient (1248)
    What exactly do you mean? From your example, the line wrap comes from your
    own code. If you don't want it there... take it out.

    I'm guessing it's not entirely clear as to the circumstances that line gets
    broken (because it's certainly not what you're suggesting).

    Elaboration?
    --

    Adam
    Adam Cameron Guest

  6. #5

    Default Re: Regular Expression - Need Help

    Adam,

    The line is broken. I am importing this text from a file and in some instances this sort of line wrap happens. So I need a way to make it one long line.

    Thanks

    Andy
    _andyK Guest

  7. #6

    Default Re: Regular Expression - Need Help

    [url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000987.htm[/url]

    You probably wannna look at \s
    --

    Adam
    Adam Cameron Guest

  8. #7

    Default Re: Regular Expression - Need Help

    Adam,

    Thanks, I tried it but I can not figure out how to get the reg expression
    syntax:

    <cfset input = REreplaceNoCase (input,
    "[a-z][[:cntrl:]]([a-z])[[:cntrl:]]+\1","\1","ALL")>
    and
    <cfset input = REreplaceNoCase (input, "[a-z]\s([a-z])\s+\1","\1","ALL")>

    Neither one of these captures the pattern that I am looking for.

    Thanks

    Andy


    _andyK Guest

  9. #8

    Default Re: Regular Expression - Need Help

    You may have carriage returns and line feeds (ascii 13 and ascii10,
    respectively) in your string. You can remove them with the code below.



    <CFSET foo = REReplace(yourString, "#Chr(13)#|#Chr(10)#", " ", "ALL")>

    jdeline Guest

  10. #9

    Default Re: Regular Expression - Need Help

    <cfset input = REreplaceNoCase (input, "[a-z][[:cntrl:]]([a-z])","\1","ALL")> is the closest I have gotten to make this work but it still fails
    The chr.. didn't accomplish anything

    Thanks

    Andy
    _andyK 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