2017-12-18 64 views
3

如何識別字符串中顯示爲空白的字符?識別隱藏的字符

的字符串(實際上,有前一個空行,但它不能在StackOverflow上的解析器顯示):

​ \n 
​\n 
\n 

當我將其粘貼在regex101.com嘗試正則表達式添加到消除這種間距/字符作爲粘貼:

enter image description here

...這也解釋了爲什麼trim()沒有看到它作爲空的空間。

我怎樣才能找出哪些字符產生這些子彈,所以我可以修剪它們?

+0

這些項目符號是Unicode字符嗎? – bassxzero

+0

[Unicode Whitespaces](http://www.fileformat.info/info/unicode/category/Zs/list.htm)? [Unicode Bullet Points](https://stackoverflow.com/questions/12971187/what-would-be-the-unicode-character-for-big-bullet-in-the-middle-of-the-characte)? –

+0

如果你在Linux上,請執行以下操作:https://unix.stackexchange.com/a/227838/237448 – Edwin

回答

1

我會做的是解析字符串並獲得ASCII字符

$str = str_split('your string here'); 
foreach($str as $char) echo ord($char); 

你再有字符的ASCII碼。理論上你可以從那裏向後工作