Loading ...
Sorry, an error occurred while loading the content.
 

Help with RE

Expand Messages
  • portos_latinos
    Hello, I wanted to know how to catch this with a regular expression: i have a file like this ... VARIABLE STRING is a variable. NON_REG_MSG_RECUS is a
    Message 1 of 4 , Sep 2, 2005
      Hello,

      I wanted to know how to catch this with a regular expression:

      i have a file like this


      ----------------------------------------------------
      ----- NON_REG_MSG_RECUS ------- VARIABLE STRING------
      ----------------------------------------------------


      ------- are some ramdom characters.
      VARIABLE STRING is a variable.
      NON_REG_MSG_RECUS is a constant.

      Thanks
    • merlyn@stonehenge.com
      ... portos i have a file like this portos ---------------------------------------------------- portos ----- NON_REG_MSG_RECUS ------- VARIABLE STRING------
      Message 2 of 4 , Sep 2, 2005
        >>>>> "portos" == portos latinos <portos_latinos@...> writes:

        portos> i have a file like this


        portos> ----------------------------------------------------
        portos> ----- NON_REG_MSG_RECUS ------- VARIABLE STRING------
        portos> ----------------------------------------------------


        portos> ------- are some ramdom characters.
        portos> VARIABLE STRING is a variable.
        portos> NON_REG_MSG_RECUS is a constant.

        How much after NON_REG_MSG_RECUS do you want to capture?
        You have some "---" there, but do you want those? Or how do you
        know to ignore those? What defines those?

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
      • portos_latinos
        There is a exemple of the lines : 09/02/05 08:18:14.363 1396 [4] ALRTC - Ecriture du nouveau document dans la BAL Militaire Locale [1689
        Message 3 of 4 , Sep 2, 2005
          There is a exemple of the lines :


          09/02/05 08:18:14.363 1396 [4] ALRTC - Ecriture du nouveau document
          dans la BAL Militaire Locale [1689
          D:\ATELIER\CURRENT_release\SOURCE\MessagesAnalyzer.cpp]

          09/02/05 08:18:14.394 1396 [4] NON_REG_MSG_RECUS [Message reçu : "Fri
          Sep 02 10:16:54 CEST 2005"] [3121 D:\ATELIER\CURRENT_release\SOURCE]


          9/02/05 08:18:15.910 928 [4]
          I want to catch if a line have NON_REG_MSG_RECUS Fri Sep 02
          10:16:54 CEST 2005 for exemple on it.

          VARIABLE STRING=Fri Sep 02 10:16:54 CEST 2005 in this case.
        • merlyn@stonehenge.com
          ... portos 09/02/05 08:18:14.394 1396 [4] NON_REG_MSG_RECUS [Message reçu : Fri portos Sep 02 10:16:54 CEST 2005 ] [3121 D: ATELIER CURRENT_release SOURCE]
          Message 4 of 4 , Sep 2, 2005
            >>>>> "portos" == portos latinos <portos_latinos@...> writes:

            portos> 09/02/05 08:18:14.394 1396 [4] NON_REG_MSG_RECUS [Message reçu : "Fri
            portos> Sep 02 10:16:54 CEST 2005"] [3121 D:\ATELIER\CURRENT_release\SOURCE]


            portos> 9/02/05 08:18:15.910 928 [4]
            portos> I want to catch if a line have NON_REG_MSG_RECUS Fri Sep 02
            portos> 10:16:54 CEST 2005 for exemple on it.

            portos> VARIABLE STRING=Fri Sep 02 10:16:54 CEST 2005 in this case.

            So you want any text between quotes following your target string?

            That'd look like this:

            while (<>) {
            if (/NON_REG_MSG_RECUS.*?"(.*?)"/) {
            print "found $1";
            }
            }

            [Aside, to the rest of the mailing list... NOTE that this wasn't
            a FAQ... and I was willing to ask questions, and answer them. *this*
            is the way this mailing list works. Not people asking FAQs.]

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
            See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
          Your message has been successfully submitted and would be delivered to recipients shortly.