Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > match pattern *********

Reply
Thread Tools

match pattern *********

 
 
ela
Guest
Posts: n/a
 
      08-03-2008
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?


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      08-03-2008
"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
 
Reply With Quote
 
 
 
 
Hartmut Camphausen
Guest
Posts: n/a
 
      08-03-2008
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
 
Reply With Quote
 
Tad J McClellan
Guest
Posts: n/a
 
      08-03-2008
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/"
 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      08-04-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re.sub(): replace longest match instead of leftmost match? John Gordon Python 13 12-20-2011 02:58 AM
pat-match.lisp or extend-match.lisp in Python? ekzept Python 0 08-10-2007 06:08 PM
Match doesn't match Volkan Civelek Ruby 4 07-19-2006 07:44 AM
$match = true() for empty $match?? Victor XML 2 05-17-2004 10:43 AM
Java regex can't match lengthy match? hiwa Java 0 01-29-2004 10:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57