04-05-2022, 03:46 AM | #706 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
Thanks.
That was one of the suggestions I had found by searching for how to match any string. I note that the expression above is not in brackets. I think that when I was trying I put it it inside brackets, which is probably why it did not work for me. I am very much a novice when it comes to regex. |
04-08-2022, 09:27 AM | #707 | |
Junior Member
Posts: 7
Karma: 591908
Join Date: Jun 2011
Device: Kindle
|
Find long ID strings
Quote:
([^>]+)(.*?) eg. <a name="Chapter_LIII" id="Chapter_LIII"></a> <a([^>]+)(.*?)></a> In you case you are using id="([^>]+)(.*?)" |
|
Advert | |
|
04-08-2022, 09:49 AM | #708 | |
Well trained by Cats
Posts: 29,820
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
[ ] is a set/range of possibilities { } is number of repetitions Get yourself a REGEX cheat sheet |
|
04-08-2022, 10:44 AM | #709 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
Thanks all.
Looks like I will have to start studying up on REGEX |
04-08-2022, 05:00 PM | #710 |
Resident Curmudgeon
Posts: 74,049
Karma: 129333562
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
Advert | |
|
04-08-2022, 06:56 PM | #711 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
id="[^"]+"
|
04-09-2022, 04:10 AM | #712 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
This is why I find REGEX so confusing.
When I was searching various REGEX sites for the code I could not find a clear answer, and it appears from your replies there are numerous ways of achieving the same result. Becky - "[A-Fa-f0-9-]+" theducks - ".+?" BillPearl - "([^>]+)(.*?)" JSWolf - "(.*)" and DiapDealer - "[^"]+" I only tried Becky's solution, which worked perfectly, but I assume all the above would have achieved the same result. So I'm now even more confused. My poor septuagenarian brain is never going to cope But thanks to everyone for their suggestions - I have noted them all for future reference. |
04-09-2022, 04:46 AM | #713 | |
Resident Curmudgeon
Posts: 74,049
Karma: 129333562
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
04-09-2022, 05:23 AM | #714 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
For the record: my expression was in response to @theducks and @jswolf's expressions for. finding ANY content between the quotes of id="".
Use regular-expressions.info for learning. |
04-09-2022, 08:18 AM | #715 |
Guru
Posts: 658
Karma: 4568205
Join Date: Jan 2010
Location: Sweden
Device: Kobo Forma
|
I want to catch some hrefs.
This catches all: <a href=".*?">(.*?)</a> \1 I want to only get those that have the word "smil" somewhere within the link. href=" smil " I have tried many ways, but I can't seem to understand regex good enough... |
04-09-2022, 08:48 AM | #716 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
<a [^>]*href="[^"]*smil[^"]*">[^>]*</a>
That's off the cuff and with no captures, but it should be close. And that's "smil" within the href quotes, not within the link text. |
04-09-2022, 08:49 AM | #717 |
A Hairy Wizard
Posts: 3,101
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
href=".*?(?<=smil).*?">(.*?)</a>
edit: dangit - ninja'd again |
04-09-2022, 09:00 AM | #718 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Actually, I'd probably include an extra [^>]* before the > of the opening 'a' tag in case there's attributes that follow href.
<a [^>]*href="[^"]*smil[^"]*"[^>]*>[^>]*</a> |
04-09-2022, 09:02 AM | #719 |
Grand Sorcerer
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
04-09-2022, 09:12 AM | #720 |
Guru
Posts: 658
Karma: 4568205
Join Date: Jan 2010
Location: Sweden
Device: Kobo Forma
|
You guys are awesome, thanks.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Examples of Subgroups | emonti8384 | Lounge | 32 | 02-26-2011 06:00 PM |
Accessories Pen examples | Gunnerp245 | enTourage Archive | 15 | 02-21-2011 03:23 PM |
Stylesheet examples? | Skitzman69 | Sigil | 15 | 09-24-2010 08:24 PM |
Examples | kafkaesque1978 | iRiver Story | 1 | 07-26-2010 03:49 PM |
Looking for examples of typos in eBooks | Tonycole | General Discussions | 1 | 05-05-2010 04:23 AM |