View Single Post
Old 10-18-2021, 06:02 AM   #37
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by firsikov View Post
Hi there!

I have code like that:
Code:
<p class="text">some text</p>
<blockquote class="email">
   <p class="text">some <i>text</i></p>
   <p class="text"><b>some</b> text</p>
   <p class="text">some text</p>
</blockquote>
<p class="text">some text</p>
And i need to change class of P tag only inside of blockquote tag.

Regex search string, like "<blockquote class="email">(.*?)<p class="text">(.*?)</blockquote>" work only if blockquote have only one p tag.

I don't understand, how to create correct search string or even how to ask google for it.

Hope for your help. Thanks.
Just to check, you want to change the class of the paragraph within the blockquote from "text" to something else? If so, it does work, but, you need to have the "Dot all" option selected. And the replace string is:

Code:
<blockquote class="email">\1<p class="newclassname">\2</blockquote>
But, I would do this with:

Code:
(<blockquote class="email">.*?<p class=")text(">.*?</blockquote>)
And the substitution is:

Code:
\1newclassname\2
Which is basically to use all the put the constant bits into groups and the bit you want to change not selected. This also needs the "Dot all" option to be selected.

For both, you have to run them multiple times. If you do "Replace all", it only makes one change in each blockquote.
davidfor is offline   Reply With Quote