0

I have a .txt file like this:

ali is a writer
ahmad is an instructor


Note: Space between words are created by Tab
and need to change it to this form:

ali
is a writer
ahmad
is an instructor

how can I tell notepad++ to retrieve those first tabbed words and place the rest of the sentence in the next line?

4
  • is there a tab character after ali? is it 'ali<tab>is a writer' ?
    – MAKZ
    Jul 26, 2014 at 16:14
  • if it is ali<tab>is a writer, do as imgur.com/eWQ55xT . remember to untick . matches newline
    – MAKZ
    Jul 26, 2014 at 17:41
  • there is a tab like as you wrote,i would like learn write these codes myself, where can i learn these codes?
    – alireza
    Jul 26, 2014 at 18:24
  • regular-expressions.info
    – MAKZ
    Jul 26, 2014 at 18:27

2 Answers 2

1

Corrected:
OK, I got it now.

Ensure that the 'Regular Expression' is selected.
Place "^([^\t]*)\t([^\r])" (without quotes) in find box.
Place "\1\r\2" (without quotes) in replace box.
Move cursor to start of file.
Select 'Replace All'

1
  • i need to replace only first tab char of each line by newline char, in suggested way all of them will be replaced.
    – alireza
    Jul 26, 2014 at 15:39
0

First, I can't get it to match regular expression tabs, so just do an "extended" find replace, replacing "\t" (tab) with " " (space). We'll undo this later to get you your desired result.

After that, change the Search mode to "Regular expression"

In the "find what" box, enter this, without quotes. Note the space at the end. "(^[a-zA-Z]*) ".

"^" means the start of the line. "[a-zA-Z]" means any letters from a-z, capitalized or not. "*" means any number of repetitions of the preceding thing (the a-z thing). The parentheses are used to remember what was found and re-use it in the "replace with box".

In the "replace with" box, enter this, without quotes: "\1\r\n"

"\1" repeats what it found between the parentheses from the "find what" box. Unfortunately, this will also repeat the space. We'll deal with that later. "\r\n" is a new line (carriage return, line feed, which is how Windows does a new line)

Click Replace All. That should basically do what you want.

Now to fix the little things:

Switch back to "extended" mode. Replace " " with "\t" to change those spaces back to tab.

Now, to fix that trailing tab after ali and ahmad:

Find what: "\t$" ($ means end of line) Replace with: "" (nothing)

Then I think you're done!

Does this do what you want?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .