String Search containing a '/' character

Discussion in 'Perl Misc' started by Bumble, Mar 7, 2004.

  1. Bumble

    Bumble Guest

    Basically I have a date, say 02/04, in a text file. I need to find that so
    i've got

    if ($line=~m/\d\d??\d\d/)

    to find the 2 lots of digits (the date and month) but I can't work out how I
    add the / in there (in place of the ??) I've tried a few things but nothing
    is working?

    --
    Bumble
     
    Bumble, Mar 7, 2004
    #1
    1. Advertising

  2. Bumble

    gnari Guest

    "Bumble" <> wrote in message
    news:c2g5aj$bkh$...
    > Basically I have a date, say 02/04, in a text file. I need to find that so
    > i've got
    >
    > if ($line=~m/\d\d??\d\d/)
    >
    > to find the 2 lots of digits (the date and month) but I can't work out how

    I
    > add the / in there (in place of the ??) I've tried a few things but

    nothing
    > is working?


    but have you tried reading the docs ?
    perldoc perlre

    gnari
     
    gnari, Mar 7, 2004
    #2
    1. Advertising

  3. Bumble

    Anno Siegel Guest

    Bumble <> wrote in comp.lang.perl.misc:
    > Basically I have a date, say 02/04, in a text file. I need to find that so
    > i've got
    >
    > if ($line=~m/\d\d??\d\d/)
    >
    > to find the 2 lots of digits (the date and month) but I can't work out how I
    > add the / in there (in place of the ??) I've tried a few things but nothing
    > is working?


    Did "a few things" include escaping the "/" with a backslash? That isn't
    the best method, but it is certainly something to try, and it works.
    It's better to use an alternative delimiter instead of "/". So both
    "/\d\d\/\d\d/" and "m!\d\d/\d\d!" should work.

    Anno
     
    Anno Siegel, Mar 7, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff S
    Replies:
    12
    Views:
    13,871
    Jeff S
    Nov 10, 2003
  2. Brand Bogard

    8 bit character string to 16 bit character string

    Brand Bogard, May 25, 2006, in forum: C Programming
    Replies:
    8
    Views:
    741
    those who know me have no need of my name
    May 28, 2006
  3. Bob Hatch
    Replies:
    3
    Views:
    195
    Brian Candler
    Feb 1, 2011
  4. Bob Hatch
    Replies:
    3
    Views:
    128
    Robert Klemme
    Feb 4, 2011
  5. Bart Vandewoestyne
    Replies:
    8
    Views:
    742
    Bart Vandewoestyne
    Sep 25, 2012
Loading...

Share This Page