Community
    • Login

    Replace content between string that contains a specific word

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    13 Posts 3 Posters 644 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.
    • Marius MasYM
      Marius MasY @PeterJones
      last edited by

      @PeterJones
      i cant make it with the plugin also, and my line is like

      },{\ "host\ ":\ "ok\ ",\ "type\ ":\ "sub\ ",\ "url\ ":\ "https:// ok. ru/videoembed/7335889799713\ "},{

      without the spaces

      thank you, ill try to find another way or tools if i cant here

      1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson
        last edited by

        I’m the JsonTools maintainer.
        Pretty sure that with JsonTools, if you have an array of objects, and you want to select only those objects where the url field contains ok.ru, you can just run the query @[@[:].url =~ `ok\.ru`].
        I don’t have a computer handy, so I can’t be of more than limited assistance.

        1 Reply Last reply Reply Quote 1
        • Marius MasYM
          Marius MasY
          last edited by

          or at least is there an way to find all sentence like:

          {\ "host\ ":\ "ok\ ",\ "type\ ":\ "sub\ ",\ "url\ ":\ "https:// ok. ru/videoembed/7335889799713\ "},

          i try {\ "host\ ":\ "ok\ ",\ "type\ ":\ "sub\ ",\ "url\ ":\ "https:// ok. ru/videoembed/([0-9]*)\ "}, but is not working also

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Marius MasY
            last edited by

            @Marius-MasY ,

            Please, please read Formatting Forum Posts, as I linked to you before. Your example data and regexes are not coming across as I believe you intend, which makes your questions/replies essentially unintelligible.

            On your first post, I could guess what you intended. But the last few have been indecipherable to me. As such, I cannot help you anymore, and anyone else who tries will just be guessing what you actually meant.

            Marius MasYM 1 Reply Last reply Reply Quote 1
            • Marius MasYM
              Marius MasY @PeterJones
              last edited by

              @PeterJones im asking the same thing, but if i cant get the sentence between {…} at least i want to find and replace something like {\ "host\ ":\ "ok\ ",\ "type\ ":\ "sub\ ",\ "url\ ":\ "https:// ok. ru/videoembed/random number\ "} and the problem is the \ (slash) when i try to use expressions

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Marius MasY
                last edited by

                @Marius-MasY,

                im asking the same thing

                I cannot believe your text has all the backslashes that we see in your post:
                7eac1e33-200e-48d1-b700-23e5d2b385da-image.png

                Does your text really have all those backslashes? Because your original post did not have all those backslashes, but your followon text does. If your real text does not, then read the FAQ on how to format your question. If you want an answer, format your text so that it acurately reflects the text you have. We cannot help you if you don’t share the text you actually have.

                Marius MasYM 1 Reply Last reply Reply Quote 2
                • Marius MasYM
                  Marius MasY @PeterJones
                  last edited by

                  @PeterJones yes it has all the backslashes, in the first post it didn’t had cuz the editor here hide it, and i saw it after i post, and i have to add space after every backslashes so you can see it

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Marius MasY
                    last edited by

                    @Marius-MasY ,

                    So there are really backslashes but not spaces? That means your post is still not showing the actual data? All you have to do to show us the real data is to hit the </> button on your post’s toolbar and paste the data in between. It’s really quite simple to do, and reading the FAQ would have shown you how days ago.

                    We still cannot help you until you show your actual data.

                    Marius MasYM 1 Reply Last reply Reply Quote 3
                    • Marius MasYM
                      Marius MasY @PeterJones
                      last edited by

                      @PeterJones

                      {\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://ok.ru/videoembed/7335889799713\"}
                      

                      this is it

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @Marius MasY
                        last edited by PeterJones

                        @Marius-MasY ,

                        So if I’ve understood correctly, the text here has two copies of what you don’t want and two copies that would be okay to keep

                        {\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://something.else/videoembed/7335889799713\"},{\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://ok.ru/videoembed/7335889799713\"},{\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://something.else/videoembed/7335889799713\"},{\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://ok.ru/videoembed/7335889799713\"}
                        

                        If you want to turn the ok.ru versions into just {}, then just
                        FIND = {[^}]*ok\.ru[^}]*}
                        REPLACE = {}

                        That will find any {...} that has the literal ok.ru in it, and turn it into just {}, and it shouldn’t ever grab too much. It will end up with

                        {\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://something.else/videoembed/7335889799713\"},{},{\"host\":\"ok\",\"type\":\"sub\",\"url\":\"https://something.else/videoembed/7335889799713\"},{}
                        

                        If your data is ever much different from the example you showed, I make no guarantees.

                        Good luck.

                        Marius MasYM 1 Reply Last reply Reply Quote 3
                        • Marius MasYM
                          Marius MasY @PeterJones
                          last edited by

                          @PeterJones it is working good, thank you much

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