Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for changing spaces to tabs in Notepad++

I'm trying to use regular expression in Notepad++ to change spaces to tabs in something like this

01 fsdfsd

01 01 fsdfsd

01 01* fsdfsd

01 01 01 fsdfsd

01 01 01* fsdfsd

How can I keep spaces between numbers and change only the last space?

Thanks.

like image 996
szpon Avatar asked Oct 27 '12 18:10

szpon


1 Answers

Search for:

[ ]([a-zA-Z])

(Note that there is a space in front of the character class.) And replace with:

\t$1

An alternative that might be better suited if you also have lines that are of a different format, or if fsdfsd may contain spaces, is this:

^((?:\d+\*?)(?:[ ]\d+\*?)*)[ ]

Now replace with

$1\t

This matches any space after the longest possible string of digits with optional asterisks separated by spaces.

like image 171
Martin Ender Avatar answered Sep 27 '22 17:09

Martin Ender