regex - Convert spaces of all sizes to a standard space in PHP? -


was wondering if there clean way replace space character variants (half space, full-width space, chinese space, etc.) standard space?

bonus points replacing multiple spaces in row (like 3 half-width or zero-width spaces or of each) single normal space.

i'll go obvious regular expression.

preg_replace('~\s+~u', ' ', 'your    input   here'); 

see http://php.net/manual/en/function.preg-replace.php


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -