Regex: I cannot find and replace unless I copy to another file
-
I have this regex, very good:
([^>])(\r\n)(<p class="mb-40px">)I have an html page, UTF-8-bom, or simple UTF-8. My problem is that in the actual html, the regex cannot find anything on search.
The strange thing is that, if I copy all the html content into another empty files, txt or html, the Regex works great and succeeded to make the Find and Replace.
<p class="mb-40px">En 1526, Buonarrotipropuso un nuevo proyecto a los Della Rovere (el cuarto), esta vezrealmente como una tumba mural; los herederos respondieron amenazándole con una demanda judicial. Finalmente, en 1532, se llegó a un nuevo acuerdo sobre la base de un nuevoproyecto ( el quinto), que manteníala estructura arquitectónica del de 1516(el tercero), aunque simplificaba ladecoración, que para el gusto de laépoca era ya excesivamentedetallista y anticuada. Los dosesclavos realizados en 1513-14 eran inútilesahora, Miguel Ángel los regaló a RobertoStrozzi, un noble florentino amigo suyo, oponente político de los Médici,que vivía entonces (tras la última restauración de los Médici) en Roma. Strozzia su vez los regaló diez años más tarde a Francisco I de Francia , y así escomo tras haber pasado por varias colecciones francesas se incorporaron a comienzos del siglo XIX, a las coleccionesdel Louvre .</p> <p class="mb-40px">Decisiva también, de <p class="mb-40px">otro modo, fue la oportunidad de <p class="mb-40px">adquirir lo que habían de ser dos pilares <p class="mb-40px">fundamentales de su formación intelectual: <p class="mb-40px">latín y prácticamente ninguno del griego <p class="mb-40px">anotadas, eran objeto de comentario cotidiano en la Apolo.</p>Why does this happen? Why do I have to copy all the code to another file, for that Regex to succeed in Find and Replace?
-
@Neculai-I-Fantanaru said in Regex: I cannot find and replace unless I copy to another file:
(\r\n)
\r\n is for a windows file. As your html may have come from a linux host it may not use exactly that sequence. I think \r is linux and \n is Mac. You could use \R which means all types.
Look at the original file in Notepad++ and use View, Show Symbol and select either End of Line or Show All Characters to confirm my prognosis.
Terry
-
@Terry-R said in Regex: I cannot find and replace unless I copy to another file:
I think \r is linux and \n is Mac
other way around,
\nis Linux (and also cmd and Powershell) and\ris Mac.
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