in reply to Re: pattern matching for string [SYN, ACK]
in thread pattern matching for string [SYN, ACK]

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: pattern matching for string [SYN, ACK]
by davido (Cardinal) on Sep 14, 2006 at 06:03 UTC

    So the specification changed? It seems that the rules for what you would like to match have expanded since your original post. Are you trying to match to capture? Or are you trying to match to reject strings that don't fit? I repeat, what are you trying to accomplish. What is it that you're doing; the bigger picture. It may be clear to you, but it's still quite vague to us.

    A pattern that matches all of the above could be:

    m/\[SYN(?:, (?:ACK|FIN|RST))?\]/

    There's an accurate answer to your question, as asked. Do you now care to elaborate so that our answers can be a little more specific, or have we answered your question satisfactorily?


    Dave

Re^3: pattern matching for string [SYN, ACK]
by ikegami (Patriarch) on Sep 14, 2006 at 06:06 UTC

    I'm still not clear on what you want.

    Maybe you want:

    $user_string = "[SYN, ACK]"; if ($x =~ /\Q$user_string\E/) { print("match\n"); } else { print("no match\n"); }

    Maybe you want:

    $user_string = "[SYN, ACK]"; if ($x =~ /(\[.*?\])/) { if ($1 eq $user_string) { print("match\n"); } else { print("no match\n"); } } else { print("not even close\n"); }

    By the way, use &#91; for [ and &#93; for ] in your posts. Better yet, don't escape anything and place code and code bits within <c>...</c> tags.

      hey man, the first solution seems to be working because my strings could have any pattern including the SYN, SYN, ACK etc.. Thanks a lot for for the effort and valuable time.. Hemal