Home > Enterprise >  Regex replace for quotes and double quotes in react native doesn't work
Regex replace for quotes and double quotes in react native doesn't work

Time:10-20

How to allow the double quotes (") and single quote (') in react native

I was unable allow those, when i try in the web it's work for me but when i try it into react native in ios simulator the single quotes and double quotes are always replace

here is the code

const regexReplace = value.replace(/[^\w\s_.,-/#-'"]/g, '');

is there is something in react native made single quotes and double quotes are not escape from the regex validation

CodePudding user response:

You need to support both straight and curly quotes.

Thus, you can use

/[^\w\s.,-/#-'"‘’“”]/g

See the , , and added to the character class.

  • Related