escaping for regexp ???

U

Une bévue

i've a regexp like that :

/.*#{name}$/ === path

however the variable "name" could, for example, in the form of :

"L2 Cache (per CPU)"

then, the string "name" might contain reserved chars for regexp,

i plan to escape them replacing "(" by "\\(" etc...

however i wonder if such a function for escaping reserved chars does
exists buit-in ???

notice i don't want to escape ".*" because i plan to use the wild card.
 

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

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top