PaulWill
PaulWill

Reputation: 623

Find Tab at beginning of string and replace

I am using this to find ^\t+ a tab at the beginning of the string and replace it with a space, the issue is that if the string has more than one tab it wont replace it with multiple spaces. how can i replace the tab on the beginning with the same amount of spaces?

Upvotes: 1

Views: 1999

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626794

You may use

\G\t

See the regex demo

The \G matches the start of string and the end of the previous successful match and \t will match 1 tab. With multiple search mode enabled (global mode), you will replace each tab at the start of the string with a space.

If you deal with tabs at the beginning of a line, you may use

(?:^|\G)\t

This expression was tested and works well in Notepad++.

Upvotes: 2

Related Questions