S
S
Senseich2022-02-08 10:54:12
Regular Expressions
Senseich, 2022-02-08 10:54:12

How to remove extra spaces without string concatenation?

Hello!
I'm trying to write a regular expression for Notepad++ to clean the text from extra spaces.
I found such an option on the Internet. \s{2,}
It cleans spaces, but also combines all lines into one, how to avoid this?

Those. yes i have 2 lines

Стол     	    180 * 90 * 75	   1 шт   
Стул с подлокотниками 	      60 * 60 * 85	   6 шт


The controller does this
Стол 180 * 90 * 75 1 шт Стул с подлокотниками 60 * 60 * 85 6 шт


It needs to be like this
Стол 180 * 90 * 75 1 шт 
Стул с подлокотниками 60 * 60 * 85 6 шт

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dollar, 2022-02-08
@Senseich

\sis any whitespace character, including the newline character.
It is enough to replace it with "" (space), and then only spaces will be replaced.
You can also specify not any whitespace character in the form \s, but a class of specific characters in square brackets. For example, spaces + tab characters. It will turn out like this:
[ \t]{2,}

D
dodo512, 2022-02-08
@dodo512

\h{2,}

S
SOTVM, 2022-02-08
@sotvm

in notepad++ there is such a function
if under linux, then Geany

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question