How to add a blank space and a word before every comma in some meta tags in every html file of a folder?
-
@Ramanand-Jhingade said in How to add a blank space and a word before every comma in some meta tags in every html file of a folder?:
You are talking of what is available here: Notepad User Manual right?
Yes. Specifically, as I posted earlier:
Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ.
-
Yes and more precisely :
-
https://npp-user-manual.org/docs/searching/ about the general concept of searching
-
https://npp-user-manual.org/docs/searching/#regular-expressions about regular expressions
A valuable site (and the reference !) is that one, too ( not especially devoted to the
Boost
regex library, used within N++ ) :And begin with https://www.regular-expressions.info/quickstart.html
Of course, you need two weeks, minimum, to feel at ease with simple goals and, let’s say, three months to become fluent to regex syntaxes in order to modify
90 %
texts as you want to, about. For the remaining10 %
you’re welcome and we’ll probably find out a suitable solution !Note that, with the knowledge of basic regexes syntax, the provided solutions should enlighten you much better than at present, without the necessary background !
BR
guy038
-
-
@guy038 I was able to do what I wanted by using this Regex in the “Find All” field:
(?-s)(?-i:<META\x20|(?!\A)\G).*?\Kcure
and thiscure\x20for
in the “Replace in Files” field. Thanks for the idea. Now, a lot of people will find this page through search engines, so just for their convenience and information please do let us know how to search for more than one string of characters and add a word with a space to the end of that string but where the search is limited to the Meta tags (it should not search the rest of the file) -
@guy038 This:-
SEARCH(?-s)(?-i:<META\x20|(?!\A)\G).*?\K(?-i:Homeopathic (treatment|doctor|clinic|specialist)|Homeopathy)
REPLACE ALL
$0\x20for
did not work for me! -
How about this bro?
-
@Reza-Saputra I already searched for each word individually and replaced each with the code I posted for searching for the word, “cure” which was originally given by @guy038 that is
(?-s)(?-i:<META\x20|(?!\A)\G).*?\Kcure
and thiscure\x20for
However, I can tell you thath
findsone horizontal whitespace character: tab or Unicode space separator
that is it! -
Hello, @ramanand-jhingade,
You said :
please do let us know how to search for more than one string of characters and add a word with a space to the end of that string but where the search is limited to the Meta tags (it should not search the rest of the file)
Well, from the two parts of this previous post and from what I specifically wrote to @peterjones, here, you should had guessed how to do it !
Indeed, from the generic regex :
SEARCH
(?-s)(?-i:
BSR|(?!\A)\G).*?\K(?-i:
FR)
REPLACE RR
where :
-
BSR is the Begin Search-region Regex expression to search BEFORE any FR string located in current line
-
FR is the Find Regex expression, which may be present once or several times in current line
-
RR is the Replace Regex expression, which replaces any FR expression found in current line
we can build up the suitable regex in order to look for, let’s say,
4
different wordsWord_1
,Word_2
,Word_3
andWord_4
, inmeta
tags only, written in a single line and add, after each of them, the wordWORD
!-
BSR ( Begin Search-region Regex ) =
<META\x20
-
FR ( Find Regex ) = Word_1
|
Word_2|
word_3|
Word_4 -
RR ( Replace Regex ) =
$0\x20
WORD
leading to the right regex S/R :
SEARCH
(?-s)(?-i:<META\x20|(?!\A)\G).*?\K(?-i:Word_1|Word_2|word_3|Word_4)
REPLACE
$0\x20
WORD
Now, you said :
SEARCH
(?-s)(?-i:<META\x20|(?!\A)\G).*?\K(?-i:Homeopathic (treatment|doctor|clinic|specialist)|Homeopathy)
REPLACE
$0\x20for
did not work for me!
Well, may be try this one :
SEARCH
(?-s)(?-i:<META\x20|(?!\A)\G).*?\K(?-i:Homeopathic\h+(treatment|doctor|clinic|specialist)|Homeopathy)
REPLACE
$0\x20for
If it does not work either, just send me your file by e-mail. Refer to this post, to get my temporary e-mail address !
BR
guy038
-
-
@guy038 I already searched for each word individually and replaced each with the code you posted here first to search for the META tag and comma. I used it to search for the word, “Homeopathy”, with this RegEx:
(?-s)(?-i:<META\x20|(?!\A)\G).*?\KHomeopathy
and replaced it with this:Homeopathy\x20for
so I will not bother you again.
I am glad you replied - I think you realised that doing this is was beyond my present abilities and comprehension! -
Just an FYI a good place to learn regex and test your code is regex101.com
-
@Acme1235 said in How to add a blank space and a word before every comma in some meta tags in every html file of a folder?:
Just an FYI a good place to learn regex and test your code is regex101.com
… which is linked to in the Regular Expression FAQ that we have repeatedly asked Ramanand to read.