How to search for occurrences of more than one space between words in a line

后端 未结 5 2031
青春惊慌失措
青春惊慌失措 2020-12-07 13:46

How to search for occurrences of more than one space between words in a line

1. this is a line containing  2 spaces
2. this is a line containing   3 spaces
3         


        
5条回答
  •  误落风尘
    2020-12-07 14:20

    This regex selects all spaces, you can use this and replace it with a single space

    \s+
    

    example in python

    result = re.sub('\s+',' ', data))
    

提交回复
热议问题