I have this string
名古屋市北区,大曽根3丁目 13-2V-
in UFT-8 encode, I want to replace (or delete) only japanese numbers with latin numbers
expected result
名古屋市北区,大曽根3丁目 12-2V-
or
名古屋市北区,大曽根丁目 -V-
how can I do it in laravel?
CodePudding user response:
Use regex :
$words = '名古屋市北区,大曽根3丁目 13-2V-';
$words = preg_replace('/\d /u', '', $words);
dd($words);
Output :
"名古屋市北区,大曽根丁目 -V-"
Explain :
\d
\d
matches a digit zero through nine in any script except ideographic scripts
Global pattern flags
u
modifier:unicode
. Pattern strings are treated asUTF-16
. Also causes escape sequences to match unicode characters
By the way, it works perfectly for :
- Arabic numerals (
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
) - Brahmi numerals (