You can use:
$foo = preg_replace('/[^\w$\x{0080}-\x{FFFF}]+/u', '', $foo);
\w
– is equivalent of[a-zA-Z0-9_]
\x{0080}-\x{FFFF}
to match characters between code pointsU
+0080and
U+FFFF`/u
for unicode support in regex
More Related Contents:
- Warning: preg_replace(): Unknown modifier
- Replace preg_replace() e modifier with preg_replace_callback
- Matching Unicode letter characters in PCRE/PHP
- Replace URLs in text with HTML links
- php regex to match outside of html tags
- Remove multiple whitespaces
- Convert plain text URLs into HTML hyperlinks in PHP
- Convert string into slug with single-hyphen delimiters only
- PHP remove special character from string
- Replace multiple newlines, tabs, and spaces [duplicate]
- Extract URL from string
- What Delimiter to use for preg_replace in PHP (replace working outside of PHP but not inside)
- Multibyte trim in PHP?
- How to remove diacritics from text?
- PHP using preg_replace : “Delimiter must not be alphanumeric or backslash” error
- Replace only first match using preg_replace [duplicate]
- Unknown modifier ‘/’ error in PHP [duplicate]
- Split string into sentences using regex
- Regex to strip comments and multi-line comments and empty lines
- Replace tabs and spaces with a single space as well as carriage returns and newlines with a single newline
- How to properly escape a backslash to match a literal backslash in single-quoted and double-quoted PHP regex patterns
- regular expression and forward slash
- Regex / DOMDocument – match and replace text not in a link
- PHP Preg-Replace more than one underscore
- Regex ignore URL already in HTML tags
- How to get the character from unicode code point in PHP?
- How to check if string is a valid XML element name?
- PHP regular expression – filter number only
- How to get the shortest rather than longest possible regex match with preg_match()
- UTF8 Filenames in PHP and Different Unicode Encodings