Tapatalk

Insert CR/LF after N words ?!??

Insert CR/LF after N words ?!??

1
NewbieNewbie
1

    Aug 21, 2006#1

    Hello!

    I need to insert a CR/LF after every two words.

    So I tried this with the search/replace function, but it doesn't work.

    Searching for ^(*^) ^(*^) finds two words, but I can't replace the second space with a "^p".

    For example:
    Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism.

    should become:
    Welcome to
    the IDM
    Forum. This
    forum is
    meant as
    a user-to-user
    support mechanism.


    Can anyone help me?

    Regards from Germany!

    6,684587
    Grand MasterGrand Master
    6,684587

      Aug 21, 2006#2

      Well, you searched for

      0 or more occurrences of any character,
      followed by a single space,
      followed by 0 or more occurrences of any character.

      Because after the second * no character is following, the second * means always 0 characters.

      I suggest following UltraEdit style regex:

      Find: ^([~ ^t^p]+^)[ ^t]+^([~ ^t^p]+^)[ ^t]++
      Replace: ^1 ^2^p

      [~ ^t^p]+ = a string with at least 1 character which can have all characters except a space, a tab or a CRLF.

      Or without the tab if your file does not contain tabs:

      Find: ^([~ ^p]+^) +^([~ ^p]+^) ++
      Replace: ^1 ^2^p
      Best regards from an UC/UE/UES for Windows user from Austria