What are the difference between `\b` vs `\S` in PCRE grep?
-1
votes
1
answer
255
views
I know now that
\b
is for Word Boundaries
while
\s
and \S
is for Shorthand Character Classes
where
\s
(lowercase) is for whitespace (space, tab, vtab, newline)
and
\S
(uppercase) is the other way around. Anything but whitespace
wolf@linux:~$ cat space.txt
0space
1 spaces
2 spaces
3 spaces
4 spaces
wolf@linux:~$
I don't see any difference in these 2 commands.
wolf@linux:~$ grep -P '\S\s\S' space.txt
1 spaces
wolf@linux:~$ grep -P '\S\s\S\S' space.txt
1 spaces
wolf@linux:~$
vs
wolf@linux:~$ grep -P '\b\s\b' space.txt
1 spaces
wolf@linux:~$ grep -P '\b\s\b\b' space.txt
1 spaces
wolf@linux:~$
Reference: https://staff.washington.edu/weller/grep.html
Asked by Wolf
(1741 rep)
Oct 9, 2020, 07:48 AM
Last activity: Oct 9, 2020, 09:35 AM
Last activity: Oct 9, 2020, 09:35 AM