Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  47] [ 7]  / answers: 1 / hits: 31343  / 12 Years ago, fri, october 5, 2012, 12:00:00

Can someone provide a regular expression to search and replace illegal characters found



Example, removing �



I am not sure how many types of 'illegal' characters exist but I think this will be a good start.



Many thanks



edit - I have no control over the data, we're trying to create a catch for the potentially bad data we're receiving.


More From » regex

 Answers
38

Invalid characters get converted to 0xFFFD on parsing, so any invalid character codes would get replaced with:



myString = myString.replace(/uFFFD/g, '')


You can get all types of invalid sorts of chars here


[#82728] Thursday, October 4, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
wilson

Total Points: 27
Total Questions: 93
Total Answers: 93

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
wilson questions
Tue, Aug 9, 22, 00:00, 2 Years ago
Wed, May 11, 22, 00:00, 2 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
Wed, May 13, 20, 00:00, 4 Years ago
;