Community
    • Login

    Help with Basic Regular Expression Search

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    regex
    5 Posts 3 Posters 2.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Marshall MedoffM
      Marshall Medoff
      last edited by

      OK, folks, I’ve never used regular expressions before and it’s high time I started.

      I’m trying to edit a large txt file that has text at the end of many lines that I want to completely remove. I was able to build a search expression to remove text (actually replace it with other text) at the beginning of the lines, but, removing the ending text is proving to be a bit more difficult. I’m sure there’s a way to do it via regexp but I’m not seeing it.

      Each of the lines I want to edit has the same text in the middle of the line. I want to remove that text and the rest of the text all the way to the end of the line, preserving the CR/LF.

      Any suggestions?

      Thanks in advance!

      Colby

      1 Reply Last reply Reply Quote 0
      • 古旮古
        古旮
        last edited by

        You should describe your request more clearly, better give some examples. Then we’ll be easier to help you.

        1 Reply Last reply Reply Quote 0
        • dailD
          dail
          last edited by

          This is actually much more clear than most posts asking for regex help.

          You can use a regex like: some text.*?$

          The important part here is the .*?$ at the end which will match the text after “some text” all the way right up until it reaches the end of the line (which is what the $ represents).

          Keep in mind that if your “some text” has special characters in it such as a period, parenthesis, etc then you will need to escape the character.

          1 Reply Last reply Reply Quote 1
          • Marshall MedoffM
            Marshall Medoff
            last edited by

            So Dail, that worked! Thank you!

            In the best Reddit practice, I upvoted your response, but, does this site have the equivalent of Karma or gold?

            Best to you and yours!

            Colby

            dailD 1 Reply Last reply Reply Quote 0
            • dailD
              dail @Marshall Medoff
              last edited by

              @Marshall-Medoff

              does this site have the equivalent of Karma or gold?

              I’m not really sure how the reddit system works. The reputation here doesn’t really have much value, I think mostly just to weed out spam accounts.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors