How to convert a literal string to regex

P

Peng Yu

Suppose I have $string='().',

If I want grep such string, I should use regex /\(\)\./. Is there a
subroutine to convert '().' to '\(\)\.'?
 
W

Willem

Peng Yu wrote:
) Suppose I have $string='().',
)
) If I want grep such string, I should use regex /\(\)\./. Is there a
) subroutine to convert '().' to '\(\)\.'?

You should read the docs for regular expressions.
Especially the bit about the \Q operator.
I'm sure it will be most helpful.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top