+ 1
Help with regex
I'm trying to create a regex that would turn this string: "pain around the eyes, nose, cheeks, or forehead" To this: "pain around the eyes, pain around the nose, pain around the cheeks, pain around the forehead" I've been trying for an hour now but no luck :( Thanks in advance
6 Respuestas
+ 3
var re = /, (or)?/g;
var str = "pain around the eyes, nose, cheeks, or forehead";
var newstr = str.replace(re, ", pain around the ");
console.log(newstr);
+ 2
What have you done so far?
+ 1
Hi Diego, I've successfully captured the first 3 words, but can't capture anything after that.
/^((?:\S+\s+){2}\S+).* ([a-z]+)/
+ 1
What programming language are you using?
+ 1
AWESOME!
This works great! Thanks Diego.
0
I mainly use JavaScript, but doesn't regex have the same syntax in all languages?