Thread: Regex examples
View Single Post
Old 03-17-2025, 10:18 AM   #769
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,761
Karma: 206758686
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Pavulon View Post
<a (class="backlink")? href="(.*?)" id="(.*?)">([0-9] {1,4})</a>

In Sigil, it does not work, I only recover the link with the class. I also tried with the quantifier "*", without better result.
Does anyone know how to tell me?
Thanks.
Would your regex not make two spaces mandatory between <a and href?
I would think you'd need to make that first space optional as well.

<a( class="backlink")? href="(.*?)" id="(.*?)">([0-9] {1,4})</a>

I can't explain why your original would work on Regex 101 though.

There also appears to be space between your [0-9] character class and the {1,4}, but that could be an artifact of not pasting your regex between between code tags.

I can confirm that your regex works in Sigil if the first space in made optional (or the second space really--it doesn't matter):

Code:
<a( class="backlink")? href="(.*?)" id="(.*?)">([0-9]{1,4})</a
I wouldn't have expected the original to do what you wanted anywhere, to be honest.

Last edited by DiapDealer; 03-17-2025 at 10:31 AM.
DiapDealer is online now   Reply With Quote