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.
    • Martina MizziM
      Martina Mizzi
      last edited by

      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
      • guy038G
        guy038
        last edited by guy038

        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
        • Martina MizziM
          Martina Mizzi
          last edited by

          Thanks so much guy!

          1 Reply Last reply Reply Quote 0
          • Anandkumar PrajapatiA
            Anandkumar Prajapati
            last edited by

            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.

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Anandkumar Prajapati
              last edited by PeterJones

              @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
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors