Finding and Matching Text Up to a Newline or EOF Using EmEditor's Features

Finding and Matching Text Up to a Newline or EOF Using EmEditor's Features

Joseph Lv8

Finding and Matching Text Up to a Newline or EOF Using EmEditor’s Features

Viewing 5 posts - 1 through 5 (of 5 total)

  • Author
    Posts

  • July 14, 2011 at 12:08 am #9467
    Deipotent
    Participant
    I know you can use n to match a newline, but how do you match either newline OR EOF ?
    I want it to match all lines, including the last line, which have some specific text followed by either newline or EOF. For example, I can use “sometextn”, but this won’t match on the last line.
    July 14, 2011 at 1:23 am #9469
    CrashNBurn
    Member
    Search for: sometext$
    July 14, 2011 at 2:37 am #9475
    Deipotent
    Participant
    I didn’t mention it in my original post, but I want to replace the newline, where present. For example, suppose I have three lines:

    line1
    line2
    line3
    There is a newline character after “line1” and “line2”, but not after “line3”. I want to use a Find/Replace regex to convert it into the following:

line1A, line2A, line3A
My Find regex would be something like
([[:alnum:]]+)n
and the Replace regex would be
1A,
but this does not produce want I’m after due to it not matching the last line, so the end result is:
line1A, line2A, line3
That is, no “A, ” after “line3”.
So, I was hoping for a way to match either a n or EOF, and replace the n, but not the EOF (as that’s obviously just a virtual char).
July 14, 2011 at 2:51 am #9478
CrashNBurn
Member
I can’t reproduce what you are claiming in this case.
I’ve tried with both unix-LF and windows-CRLF files.
AString
ANotherString
YetAnotherString
EvenMoreString
This Search: ([[:alnum:]]+)n
Replace: 1,
Results in:

AString, ANotherString, YetAnotherString, EvenMoreString
July 14, 2011 at 2:58 am #9479
Deipotent
Participant
Thanks CrashNBurn! The last regex is what I’m after
([[:alnum:]]+)($n|$)

  • Author
    Posts

Viewing 5 posts - 1 through 5 (of 5 total)

  • You must be logged in to reply to this topic.

Also read:

https://techidaily.com
  • Title: Finding and Matching Text Up to a Newline or EOF Using EmEditor's Features
  • Author: Joseph
  • Created at : 2024-10-06 17:07:14
  • Updated at : 2024-10-13 17:33:55
  • Link: https://win-lab.techidaily.com/finding-and-matching-text-up-to-a-newline-or-eof-using-emeditors-features/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
Finding and Matching Text Up to a Newline or EOF Using EmEditor's Features