match pattern *********

E

ela

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

Jürgen Exner

ela said:
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
 
H

Hartmut Camphausen

ela said:
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
 
T

Tad J McClellan

Hartmut Camphausen said:
(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}/
 
J

John W. Krahn

Tad said:
Hartmut Camphausen said:
(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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top