Regular expression for matching non-whitespace in Python

后端 未结 4 1744
刺人心
刺人心 2021-01-20 01:03

I want to use re.search to extract the first set of non-whitespace characters. I have the following pseudoscript that recreates my problem:

#!/usr/b         


        
4条回答
  •  粉色の甜心
    2021-01-20 01:38

    \s matches a whitespace character.

    \S matches a non-whitespace character.

    [...] matches a character in the set ....

    [^...] matches a character not in the set ....

    [^\S] matches a character that is not a non-whitespace character, i.e. it matches a whitespace character.

提交回复
热议问题