Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

match pattern *********

0 views
Skip to first unread message

ela

unread,
Aug 3, 2008, 4:34:30 AM8/3/08
to
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?


Jürgen Exner

unread,
Aug 3, 2008, 4:39:55 AM8/3/08
to

See \Q in "perldoc perlre".

jue

Hartmut Camphausen

unread,
Aug 3, 2008, 10:13:06 AM8/3/08
to
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

Tad J McClellan

unread,
Aug 3, 2008, 11:11:54 AM8/3/08
to
Hartmut Camphausen <Jus...@somewhere.de> 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/"

John W. Krahn

unread,
Aug 4, 2008, 9:50:38 AM8/4/08
to
Tad J McClellan wrote:
> Hartmut Camphausen <Jus...@somewhere.de> 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

0 new messages