• Login
Community
  • Login

How to remove part of a phrase multiple times

Scheduled Pinned Locked Moved General Discussion
5 Posts 4 Posters 249 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.
  • M
    Martina Mizzi
    last edited by Mar 5, 2021, 10:14 AM

    I am trying to remove the part of the phrase
    “GridLink data-title=spaceship data-category-name=“space game” data-widget-event=videogame>”

    from this phrase:

    data-testid=SpaceshipGridLink data-title=spaceship data-category-name=“space game” data-widget-event=videogame>

    From multiple sentences… these all begin with gridlink and end with videogame>

    how do i go about this please? Many thanks!

    1 Reply Last reply Reply Quote 0
    • G
      guy038
      last edited by guy038 Mar 5, 2021, 1:27 PM Mar 5, 2021, 1:20 PM

      Hello, @martina-mizzi and All,

      Not difficult with regular expressions ! So :

      • Open your file with N++

      • Open the Replace dialog ( Ctrl + H )

        • SEARCH (?-si)GridLink.*?videogame>

        • REPLACE Leave EMPTY

        • Tick the Wrap around option

        • Select the Regular expression search mode

        • Click, once on the Replace All button or several times on the Replace button

      Et voilà !


      Notes :

      • The (?-si) part ensures that the search will be sensible to case and that the dot meta-character will match a single standard char, only ( Not EOL chars )

      • Then, the parts GridLink and videogame> looks for these literal strings

      • In between, the part .*? tries to match the shortest range of any standard char(s), even zero

      Best Regards,

      guy038

      1 Reply Last reply Reply Quote 2
      • M
        Martina Mizzi
        last edited by Mar 5, 2021, 1:45 PM

        Thanks so much guy!

        1 Reply Last reply Reply Quote 0
        • A
          Anandkumar Prajapati
          last edited by Mar 8, 2021, 10:39 AM

          Open your document in N++.
          Go to the start of the document by clicking on ctrl+home.
          Open The Replace Dialogue Box (ctrl+h).
          Enable Wrap around option.
          Under search, mode Select regular expression.
          Enable the .matches newline.
          write the following in the fields.
          Find what: (?s)(?i)(GridLink.*?videogame>)
          Replace with: leave this field blank.
          Click on Replace All.

          Description:
          (?s)enables dot matching newlines.
          (?i) makes match case insensitive.
          (GridLink) Literal string.
          (.*?) Matches shortest range of string.
          (videogame>) Literal string.

          P 1 Reply Last reply Mar 8, 2021, 3:13 PM Reply Quote 0
          • P
            PeterJones @Anandkumar Prajapati
            last edited by PeterJones Mar 8, 2021, 3:14 PM Mar 8, 2021, 3:13 PM

            @Anandkumar-Prajapati ,

            I am curious what you were trying to accomplish with your post. It was nearly identical content to Guy’s post. The places where you varied from Guy’s were either inconsequential, or nearly so for the original data shown.

            If you have a unique point you were trying to make with your slight differences, I don’t know what that point was – so if it really is trying to make a point, please explain yourself more. It might be educational for the original poster or future readers to know why you made the choices you did – but only if you explain why.

            Otherwise, I want to point out that rephrasing advice that has already been given looks a lot like trying to take credit for someone else’s work – which is highly frowned upon (to say the least). I try to give the benefit of the doubt in such circumstances, so I am not saying that it was intentional; but it is a good idea to read the whole thread before posting, and to try to avoid giving the same advice without adding anything new, in an effort to avoid such appearances.

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