Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  160] [ 1]  / answers: 1 / hits: 17677  / 13 Years ago, mon, october 17, 2011, 12:00:00

I'm sitting here with The Good Parts in hand but I'm still none the wiser.



Can anyone knock up a regex for me that will allow me to replace any instances of | and , from a string.



Also, could anyone point me in the direction of a really good resource for learning regular expressions, especially in javascript (are they a particular flavour??) It really is a weak point in my knowledge.



Cheers.


More From » regex

 Answers
50

str.replace(/(||,)/g, replaceWith) don't forget the g at the end so it seaches the string globally, if you don't put it the regex will only replace the first instance of the characters.



What is saying is replace | (you need to escape this character) OR(|) ,



Nice Cheatsheet here


[#89574] Saturday, October 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kevonmoisesf

Total Points: 693
Total Questions: 101
Total Answers: 128

Location: Reunion
Member since Mon, Dec 28, 2020
3 Years ago
kevonmoisesf questions
Sat, Jan 23, 21, 00:00, 3 Years ago
Tue, Feb 18, 20, 00:00, 4 Years ago
Wed, Jun 12, 19, 00:00, 5 Years ago
;