1

I am new to regular expressions, and i hope, i didn't overlook any obvious solutions for this problems, but after several hours of searching the Net, i think it is time to just ask.

I Am coding a little javascript that should eventually translate PDF. To do this i intended to use the .replace() method with regex for search. I need to create the regex-expression automatically, because i need to search for quite a few different strings. The problem i am having now, is that many of those strings include special characteres, that are used in regex to modify the search. Obviously this kind of search tends to bring up a lot of nonsense.

The solution with \Q...\E doesn't seem to work either. (I am not sure why, my guess is because i am using javascript for PDFs, and it might not be implemented there.)

I also see the solution of first replacing every single special character with itself and a preceeding "\", but the only way to do this (that i know about) would require quite a few replace methods (one for each special character). So it would not only be easy to overlook a special charcter, it would also slow down the whole process.

If any of you know a solution to this problem, i would be really thankfull!

Zoldor
  • 21
  • 5
  • Welcome to SO! Please see this question: http://stackoverflow.com/q/3561493/989121. I guess this is what you're looking for. – georg Jul 08 '13 at 09:00
  • thanks, this really did the trick! How did i not find this on my own? Well, i guess i really have to improve my way to search... – Zoldor Jul 08 '13 at 09:10

0 Answers0