What's the difference between [:space:] and [:blank:]?

懵懂的女人 提交于 2020-05-12 12:05:08

问题


From the A Brief Introduction to Regular Expressions

[:blank:] matches a space or a tab.

[:space:] matches whitespace characters (space and horizontal tab).

To me both definitions are the same and I was wondering if they are really duplicates?

If they are different, what are the differences?


回答1:


For the GNU tools the following from grep.info applies:

[:blank:]

     Blank characters: space and tab.

[:space:]

     Space characters: in the 'C' locale, this is tab, newline,
     vertical tab, form feed, carriage return, and space.

You can find the section with this command:

info grep 'Regular Expressions' 'Character Classes and Bracket Expressions'



回答2:


A better explanation of what they each match is available here

  • http://www.regular-expressions.info/posixbrackets.html

The biggest difference is that [:space:] will also match items like new line characters




回答3:


A space means to pressing a space bar and tab

A white space means it carries the newline,tab,form feed and carriage return and also space that's all.



来源:https://stackoverflow.com/questions/15767863/whats-the-difference-between-space-and-blank

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!