![]() |
#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. |
![]() |
![]() |
![]() |
#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 | |
|
![]() |
#708 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,069
Karma: 57259778
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 ![]() |
|
![]() |
![]() |
![]() |
#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 ![]() |
![]() |
![]() |
![]() |
#710 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,913
Karma: 131375774
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
Advert | |
|
![]() |
#711 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,660
Karma: 195154104
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
id="[^"]+"
|
![]() |
![]() |
![]() |
#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. |
![]() |
![]() |
![]() |
#713 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,913
Karma: 131375774
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#714 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,660
Karma: 195154104
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. |
![]() |
![]() |
![]() |
#715 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 661
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... |
![]() |
![]() |
![]() |
#716 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,660
Karma: 195154104
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. |
![]() |
![]() |
![]() |
#717 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,123
Karma: 18727091
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 |
![]() |
![]() |
![]() |
#718 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,660
Karma: 195154104
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> |
![]() |
![]() |
![]() |
#719 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,660
Karma: 195154104
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
![]() |
![]() |
![]() |
#720 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 661
Karma: 4568205
Join Date: Jan 2010
Location: Sweden
Device: Kobo Forma
|
You guys are awesome, thanks.
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |