Community
    • Login

    replace with notepad

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 1.6k Views 1 Watching
    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.
    • vilma netyV Offline
      vilma nety
      last edited by

      Hi,
      I need to replace all the sites with site:us

      site:it [number] phone2 value “source”: “Source A”
      “strength”: “0.7”, site:.de phone3 “Source D”
      “idTarget”: “1,253” site:.nz

      result

      site:us [number] phone2 value “source”: “Source A”
      “strength”: “0.7”, site:us phone3 “Source D”
      “idTarget”: “1,253” site:us

      Thnx

      1 Reply Last reply Reply Quote 0
      • guy038G Online
        guy038
        last edited by

        Hello, vilma-nety and All,

        Quite easy with regular expressions !

        • Open the Replace dialog ( Ctrl + H )

        • SEARCH (?-i)(?<=\bsite:)\.?\l\l

        • REPLACE us

        • Select the Regular expression search mode

        • Tick the Wrap around option

        • Click on the Replace All button,exclusively ( not the Replace one ! )

        Et voilà :

        Notes :

        • At beginning, the (?-i) modifier forces a non-insensitive to case search

        • The main part looks for an optional literal dot \.?, followed with a two lower-case letters \l\l, which represents the ccTLD ( Top Domains Level country code )

        Refer to :

        https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

        • But ONLY IF it is preceded with the word site, in this exact case, followed with a colon , due to the look-behind syntax (?<=\bsite:)

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 1
        • vilma netyV Offline
          vilma nety
          last edited by

          very grateful to you, guy038, I have been able to replace almost all, but those with site:.com site:.co.uk site:net, the result is:

          site:usm
          site:us.uk
          site:ust

          I’m doing it with
          Open the Replace dialog ( Ctrl + H )
          SEARCH:site:usm
          REPLACE: site:us

          with regular expressions?
          infinitely thank you guy038

          1 Reply Last reply Reply Quote 1
          • guy038G Online
            guy038
            last edited by guy038

            Hi, @vilma-nety and All,

            Ah! Sorry that my regex did not match all possible cases. I just thought that all your possible values, were like it, de, nz, … ! In other words, Internet country codes ( which, by definition, contain, all, two lower-case letters )

            So, in order to include vary common top-level domain names as .com, .net,…, the best method would be to simply consider all text, after site:, up to the first space character. Hence, this new search regex :

            SEARCH (?-is)(?<=\bsite:).+?(?=\x20)

            Notes :

            • The part .+? matches the shortest, non-null, range of standard characters, due to the -s modifier

            • ONLY IF followed with the first found space character, \x20, due to the look-ahead syntax (?=\x20). You may, simply, hit the space bar, instead of typing \x20

            Cheers,

            guy038

            1 Reply Last reply Reply Quote 1
            • vilma netyV Offline
              vilma nety
              last edited by

              a thousand and a thousand thanks

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors