Skip to main content
added 340 characters in body
Source Link
iamsaksham
  • 2.9k
  • 4
  • 31
  • 53

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

This is the character list, i want to replace, without the quotes "<3","<\/3",";p","C:","c:",":D",":-D",":/",":-/",":o",":-o",":p",":-p",":P",":-‌​P",":b",":-b",";-p",";b",";-b",";P",";-P","D:",":->",":>",":)",":-)","(:",";)",";‌​-)",":sj:","):",":(",":-(",":'(","=)","=-)",">:(",">:-(","8)",":\\\\",":-\\\\",":*",":-‌​*",":|",":-|"

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){ console.log(x); return x; } 

Unexpected token (105:52) Unexpected token (105:52)

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){ console.log(x); return x; } 

Unexpected token (105:52) Unexpected token (105:52)

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

This is the character list, i want to replace, without the quotes "<3","<\/3",";p","C:","c:",":D",":-D",":/",":-/",":o",":-o",":p",":-p",":P",":-‌​P",":b",":-b",";-p",";b",";-b",";P",";-P","D:",":->",":>",":)",":-)","(:",";)",";‌​-)",":sj:","):",":(",":-(",":'(","=)","=-)",">:(",">:-(","8)",":\\\\",":-\\\\",":*",":-‌​*",":|",":-|"

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){ console.log(x); return x; } 

Unexpected token (105:52) Unexpected token (105:52)

Post Closed as "Duplicate" by Wiktor Stribiżew regex
added 142 characters in body
Source Link
iamsaksham
  • 2.9k
  • 4
  • 31
  • 53

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){ ... console.log(x); return x; } 

Unexpected token (105:52) Unexpected token (105:52)

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){ .... } 

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){  console.log(x); return x; } 

Unexpected token (105:52) Unexpected token (105:52)

Source Link
iamsaksham
  • 2.9k
  • 4
  • 31
  • 53

Regex: How to regex the following expression

I have a text message and I want to parse the special characters in it. I have the list of special characters. I wrote the following regex but this shows compile time error. Looks like there is something with escape characters, but i'm not able to figure out.

return msg.replace(/(<3|<\/3|;p|C:|c:|:D|:-D|:/|:-/|:o|:-o|:p|:-p|:P|:-P|:b|:-b|;-p|;b|;-b|;P|;-P|D:|:->|:>|:)|:-)|(:|;)|;-)|:sj:|):|:(|:-(|:'(|=)|=-)|>:(|>:-(|8)|:\\\\|:-\\\\|:*|:-*|:||:-|)/g, function myFunction(x){ .... }