Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-13-2016, 09:32 AM   #31
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,355
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by Psymon View Post
And even though I don't know exactly what each part of "(.+?)" actually means/does, I do know what the whole shebang together does -- and that, along with "\1", "\2", etc. -- has effectively given me virtually everything that I can imagine I'd ever need to know about Regex.
Oh young padawan. Know you do not the full powers of the regex!
Turtle91 is offline   Reply With Quote
Old 07-13-2016, 12:45 PM   #32
Psymon
Chief Bohemian Misfit
Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.
 
Psymon's Avatar
 
Posts: 571
Karma: 462964
Join Date: May 2013
Device: iPad, ADE
Quote:
Originally Posted by Turtle91 View Post
Oh young padawan. Know you do not the full powers of the regex!

Oh, I'm sure! But for the moment it's hard for me to imagine having a need for "more" than what I've learned (or semi-learned) recently.

I'd be more than happy to hear (read) an example of something "totally awesome" that you feel has applicability in coding ebooks, beyond the sort of thing that I've been doing (and that I can imagine) -- indeed, I'd love it! Inspire me!
Psymon is offline   Reply With Quote
Advert
Old 07-13-2016, 01:45 PM   #33
Hitch
Bookmaker & Cat Slave
Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.
 
Hitch's Avatar
 
Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
Quote:
Originally Posted by Turtle91 View Post
Oh young padawan. Know you do not the full powers of the regex!
Best thing I've read today. And sooooooooooooooooo true.

Quote:
Originally Posted by Psymon View Post
Oh, I'm sure! But for the moment it's hard for me to imagine having a need for "more" than what I've learned (or semi-learned) recently.

I'd be more than happy to hear (read) an example of something "totally awesome" that you feel has applicability in coding ebooks, beyond the sort of thing that I've been doing (and that I can imagine) -- indeed, I'd love it! Inspire me!
Well...if you are not dealing with scanned books, some of the "most bestest" regexes might not ever be needed by you, but BOY, one of the first things I ever did, that I learned to love, love, love was when I had a scanned novel, some 500+ pages long, from print, and OHSWEETMOTHER, all the running heads and page-number-footers were, of course, left IN. As real text, rather than Word-type "headings" or "footers." Urrrrrrrrrghhhhhhhhhhhh.

In ye olden-olden days, yes, I would have tried some combination of regular searches, plus "go to next," plus manual deletion, for all of that. But when you discover that you can clean a boatload of it, using regex? Oh, baby!!!

The Regex-jedis here, like Turtle, will have other examples, I'm sure. I'm dashing out today, (<grumble, more medical torture>) so I'm not leaving actual EXAMPLES--shame on me--but I have faith in my brothers of the regex-sword.

There's almost NOTHING that excites a good display of showmanship (or showomanship) around here like a regex example!

(Also--hath thee not gone by the regex pinned thread???? Twooly?)


Hitch
Hitch is offline   Reply With Quote
Old 07-13-2016, 01:57 PM   #34
Psymon
Chief Bohemian Misfit
Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.
 
Psymon's Avatar
 
Posts: 571
Karma: 462964
Join Date: May 2013
Device: iPad, ADE
Quote:
Originally Posted by Hitch View Post
In ye olden-olden days, yes, I would have tried some combination of regular searches, plus "go to next," plus manual deletion, for all of that. But when you discover that you can clean a boatload of it, using regex? Oh, baby!!!
Well, yes, I totally agree with you -- and that's exactly the sort of thing that I've been doing with what little I've learned so far. It was a real struggle for me to try to "figure it out," though, what the correct syntax (or whatever the word is) when trying to come up with my regex string, but that "auto-tokenise" thing totally blew my mind, because you really don't have to think about it at all (much), you just insert "(.+?)" wherever the variables are in your string.

I realize that I'm undoubtedly over-simplifying my explanation here, but surely you know what I mean -- it's that "auto-tokenise" feature in Sigil that just totally makes things SO much easier, virtually a breeze.

Last edited by Psymon; 07-13-2016 at 02:02 PM.
Psymon is offline   Reply With Quote
Old 07-13-2016, 03:10 PM   #35
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,355
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by Hitch View Post
The Regex-jedis here, like Turtle, will have other examples
Why thank you! But I can't claim having reached that exalted status.
I am still getting stuck on negative lookbacks. I know they can save me so much time, but I just end up doing 3 or 4 passes instead.

The Regex examples thread is definitely helpful!
Turtle91 is offline   Reply With Quote
Advert
Old 07-13-2016, 03:56 PM   #36
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,549
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Psymon View Post
And even though I don't know exactly what each part of "(.+?)" actually means/does
For the record:

. : any character
+ : any number of times (but at least one)
? : but as few as as possible, as long as the rest of the expression still matches
( ) : and put it in a group, so it can be referred to as \1, \2, etc.
Jellby is online now   Reply With Quote
Old 07-13-2016, 05:46 PM   #37
Psymon
Chief Bohemian Misfit
Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.
 
Psymon's Avatar
 
Posts: 571
Karma: 462964
Join Date: May 2013
Device: iPad, ADE
Firstly (and briefly) to Turtle...

Quote:
Originally Posted by Turtle91 View Post
The Regex examples thread is definitely helpful!
What's the "Regex examples thread"? I did a search of the forums here for "regex examples" but didn't find anything.

Also, from Jellby...

Quote:
Originally Posted by Jellby View Post
For the record:

. : any character
+ : any number of times (but at least one)
? : but as few as as possible, as long as the rest of the expression still matches
( ) : and put it in a group, so it can be referred to as \1, \2, etc.
Oh, cool, thanks for breaking that down for me. I just interpreted the whole shebang together as "variable" -- which I guess is essentially what it means/does.

I'm not quite sure that I understand the "? : but as few as as possible, as long as the rest of the expression still matches" part, though -- in what sense as few as possible? Couldn't it go on (and on and on, ad infinitum) until it hits the next part of the matching string -- wouldn't it do that without the "?" in there anyway, just stop at that part (the next matching bit)?

Perhaps I'm overcomplicating this -- the simple answer, for my needs, is that "(.+?)" does the trick!
Psymon is offline   Reply With Quote
Old 07-13-2016, 10:01 PM   #38
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
Posts: 13,533
Karma: 78910202
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
See Regex examples
PeterT is offline   Reply With Quote
Old 07-14-2016, 03:02 AM   #39
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Go to here and press download. Print it out and stick it next to your computer. It will help you in the beginning or when things get tricky.
Toxaris is offline   Reply With Quote
Old 07-14-2016, 04:41 AM   #40
Psymon
Chief Bohemian Misfit
Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.
 
Psymon's Avatar
 
Posts: 571
Karma: 462964
Join Date: May 2013
Device: iPad, ADE
Quote:
Originally Posted by PeterT View Post
...and...

Quote:
Originally Posted by Toxaris View Post
Go to here and press download. Print it out and stick it next to your computer. It will help you in the beginning or when things get tricky.
Very cool, guys! I seem to recall this latter downloadable PDF "cheatsheet" being mentioned here (in these forums) before somewhere -- in fact, I think I saved it on my hard drive at the time, but in any case I downloaded it again.

I did start to read the posts on that Regex examples thread -- got through the first page but then began to develop a headache and had to stop.

Ha ha, I'll take another look again later, and browse through it some more, and I also subscribed to that thread, too, and so hopefully, over time, things will start to sink in. It's strange how I've always seemed to struggle with "programmy"-type stuff like this, it's as though there's a "mental block" in my brain and I'm just not really built for it. I really do think it's a knack that one either has, or just doesn't, not unlike artistic or musical aptitude, etc. Conversely, I had an old programmer/system administrator friend once who was a total whiz at this kind of thing, he could pump out the most complex code at the drop of a hat (and he was a veritable savant when it came to performing math calculations in his head), but at the same time he had virtually no sense of aesthetics -- if it was up to him, he'd have been happy if every website out on the web looked like little more than plain text files.

But anyway, not to belabour my reply here, I think I am beginning to see how I could make use of much more Regex knowledge than simply "(.+?)" -- although I do gotta say that just that, and "\1," "\2," etc., in tandem with the auto-tokenise feature in Sigil, has already truly rocked my world! But I am now thinking of one S&R thing that I've been doing that I'm sure could be much-simplified with Regex, even though it's been fairly easy to do by doing multiple "regular" S&Rs -- I'll post that query over on that thread, though, where I guess it belongs.

Thanks again, guys! I'm a slow learner (about Regex, anyway), but hopefully over time I'll get it.

(PS. Totally off-topic to this thread, but is there any way to get email notifications for every post to a thread one is subscribed to in these forums? I often like to save emails with info that I might want to find again later, but I only seem to get notification that there's something new that's been posted -- and then discover that there have, in fact, been two or more things posted. It would be great if I could get emails for all posts, though, instead.)
Psymon is offline   Reply With Quote
Old 07-14-2016, 09:40 AM   #41
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,355
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by Psymon View Post
I'm not quite sure that I understand the "? : but as few as as possible, as long as the rest of the expression still matches" part, though -- in what sense as few as possible? Couldn't it go on (and on and on, ad infinitum) until it hits the next part of the matching string -- wouldn't it do that without the "?" in there anyway, just stop at that part (the next matching bit)?
The '?' prevents the regex from being greedy...in cases where there are multiple possible matches it will take the first or shortest one.

eg

string searched:
"Hello my name is Inigo Mantoya, son of Hector Mantoya."

find: "name is (.+) Mantoya" or "name is (.*) Mantoya"

is a greedy find...it will match as much as possible and still meet the criteria: "name is Inigo Mantoya, son of Hector Mantoya"

find: "name is (.+?) Mantoya" or "name is (.*?) Mantoya"

is a non-greedy find... it will match on only the first qualifying match "name is Inigo Mantoya"

Hopefully that's clearer than mud!
Turtle91 is offline   Reply With Quote
Old 07-14-2016, 09:45 AM   #42
Psymon
Chief Bohemian Misfit
Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.
 
Psymon's Avatar
 
Posts: 571
Karma: 462964
Join Date: May 2013
Device: iPad, ADE
Quote:
Originally Posted by Turtle91 View Post
Hopefully that's clearer than mud!
Yes! It's as clear as a London fog now -- thank you!

Seriously, thanks!
Psymon is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex help anyone? seanos Editor 17 04-02-2014 11:03 AM
New help with a regex txckie Calibre 2 08-29-2011 08:46 PM
Help me with regex please. eVrajka Library Management 5 08-15-2011 12:17 PM
What a regex is Worldwalker Calibre 20 05-10-2010 05:51 AM
Help with a regex A.T.E. Calibre 1 04-05-2010 07:50 AM


All times are GMT -4. The time now is 03:00 AM.


MobileRead.com is a privately owned, operated and funded community.