replace with notepad
-
Hi,
I need to replace all the sites with site:ussite:it [number] phone2 value “source”: “Source A”
“strength”: “0.7”, site:.de phone3 “Source D”
“idTarget”: “1,253” site:.nzresult
site:us [number] phone2 value “source”: “Source A”
“strength”: “0.7”, site:us phone3 “Source D”
“idTarget”: “1,253” site:usThnx
-
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 expressionsearch mode -
Tick the
Wrap aroundoption -
Click on the
Replace Allbutton,exclusively ( not theReplaceone ! )
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
-
-
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:ustI’m doing it with
Open the Replace dialog ( Ctrl + H )
SEARCH:site:usm
REPLACE: site:uswith regular expressions?
infinitely thank you 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, aftersite:, up to the firstspacecharacter. Hence, this new search regex :SEARCH
(?-is)(?<=\bsite:).+?(?=\x20)Notes :
-
The part
.+?matches the shortest, non-null, range of standard characters, due to the-smodifier -
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
-
-
a thousand and a thousand thanks