Regular Expression help, please

Discussion in 'Perl Misc' started by Stan Brown, Sep 12, 2005.

  1. Stan Brown

    Stan Brown Guest

    I'm trying to parse some tcpdump output (converted to text) to put it into
    a database.

    The records of interest look like this:

    Which is, of course an IP address with the port number prepended. I can't
    seem to manage to come up with a regex that will match this. I tried
    something like:


    But it does not seem to work.

    Cab some kind guru enlighten me on this mystery?
    Stan Brown, Sep 12, 2005
    1. Advertisements

  2. Stan Brown

    Brian Wakem Guest

    Looks OK to me.


    use strict;
    use warnings;

    my $str = "somestuffhere170.";

    if ($str =~ m/((\d{1,5}\.?){5})/) {
    print "$1\n";
    else {
    print "No match!\n";

    $ perl
    Brian Wakem, Sep 12, 2005
    1. Advertisements

  3. Stan Brown

    Paul Lalli Guest

    "does not work" is the worst of all possible error descriptions. You
    need to tell us what didn't work, how it didn't work, what kind of
    error message you received, etc.
    perl -e'$_ = q{}; print "Yes!\n" if

    The only "mystery" here is what you're actually asking.

    Please read the Posting Guidelines, and then post a short-but-complete
    script that demonstrates your problem.

    Paul Lalli
    Paul Lalli, Sep 12, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.