Some notes on software development... RSS 2.0
# Wednesday, 26 November 2014

Before using JavaScript’s RegExp object you may need to escape regular expression characters. These characters are: ( ) [ { * + . $ ^ \ | ?

I’m no RegEx expert but the code I found that works for me is:

text.replace(/([()[{*+.$^\\|?])/g, '\\$1');

 

Thanks once again StackOverflow :-)

Links
http://stackoverflow.com/questions/5663987/how-to-properly-escape-characters-in-regexp

Wednesday, 26 November 2014 10:47:48 (GMT Standard Time, UTC+00:00)  #    -
JavaScript | Regular Expressions
Navigation

Sign In
Extras
Statistics
Total Posts: 116
This Year: 0
This Month: 0
This Week: 0
Comments: 36
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Hadrian Phillips

All Content © 2017, Hadrian Phillips
DasBlog theme 'Business' created by Christoph De Baene (delarou)