I have an array of strings and I want to replace it with a new word, s +o I do this: $line='i got a dog and a bear.'; @a=('dog','bear','camel'); $a=join('|',@a); $line=~s/\b($a)\b/beast/g; say $line; Simply works, but the problem is that @a is not hard-coded, but instea +d inputted by the user. The elements in @a will contain special char +acters like | or . etc. How do I make this regex work with the antic +ipation of those characters?
In reply to regex - replacing an array of string by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |