match pattern *********

Discussion in 'Perl Misc' started by ela, Aug 3, 2008.

  1. ela

    ela Guest

    I wanna search a string "*********" and I remember some special characters
    can be used to tell the match so I need not type something like:

    \*\*\*\*...

    Would anybody know how to do that?
    ela, Aug 3, 2008
    #1
    1. Advertising

  2. "ela" <> wrote:
    >I wanna search a string "*********" and I remember some special characters
    >can be used to tell the match so I need not type something like:
    >
    >\*\*\*\*...
    >
    >Would anybody know how to do that?


    See \Q in "perldoc perlre".

    jue
    Jürgen Exner, Aug 3, 2008
    #2
    1. Advertising

  3. ela schrieb:

    > I wanna search a string "*********" and I remember some special characters
    > can be used to tell the match so I need not type something like:
    >
    > \*\*\*\*...



    (1) See jue's hint
    (2) use the ...{}-quantifier, eg.

    /\*{5}/

    to match exactly 5 asterisks, or

    /\*{2,7}/

    to match two up to seven of them.


    Again, read
    perldoc perlre



    hth + mfg,
    Hartmut

    --
    ------------------------------------------------
    Hartmut Camphausen h.camp[bei]textix[punkt]de
    Hartmut Camphausen, Aug 3, 2008
    #3
  4. Hartmut Camphausen <> wrote:

    > (2) use the ...{}-quantifier, eg.
    >
    > /\*{5}/
    >
    > to match exactly 5 asterisks, or



    Or, if you are backslash-averse as I am, you can write it as:

    /[*]{5}/


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Aug 3, 2008
    #4
  5. Tad J McClellan wrote:
    > Hartmut Camphausen <> wrote:
    >
    >> (2) use the ...{}-quantifier, eg.
    >>
    >> /\*{5}/
    >>
    >> to match exactly 5 asterisks, or

    >
    >
    > Or, if you are backslash-averse as I am, you can write it as:
    >
    > /[*]{5}/


    Yes, but in Perl before 5.10 the backslashed version is more efficient.


    John
    --
    Perl isn't a toolbox, but a small machine shop where you
    can special-order certain sorts of tools at low cost and
    in short order. -- Larry Wall
    John W. Krahn, Aug 4, 2008
    #5
    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. hiwa
    Replies:
    0
    Views:
    624
  2. Victor
    Replies:
    2
    Views:
    625
    Victor
    May 17, 2004
  3. ekzept
    Replies:
    0
    Views:
    351
    ekzept
    Aug 10, 2007
  4. John Gordon
    Replies:
    13
    Views:
    452
    Ian Kelly
    Dec 20, 2011
  5. Volkan Civelek

    Match doesn't match

    Volkan Civelek, Jul 19, 2006, in forum: Ruby
    Replies:
    4
    Views:
    151
Loading...

Share This Page