Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 02-17-2018, 02:14 PM   #31
WS64
WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.
 
WS64's Avatar
 
Posts: 660
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / PB Lux 2 / Bookeen Frontlight / Kobo Mini / Nook Color
I uploaded a short video.
First with Minimal Matchm then without.
First search for *, then for +
And * never finds anything.

It's hard to read, but maybe it helps anyway: https://www.youtube.com/watch?v=hOtE...ature=youtu.be
WS64 is offline   Reply With Quote
Old 02-17-2018, 02:27 PM   #32
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi DiapDealer,
I agree completely. Returning a zero-length match makes no sense here for Sigil. Any search for words that returns non-words as matches is not useful. That is why that [a-zA-Z]* regular expression makes no sense as it would return everything even those with match length 0. The right regular expression to do what the user wants is [a-zA-Z]+ which works in Sigil just as expected.

KevinH


Quote:
Originally Posted by DiapDealer View Post
@KevinH:

Some regex search engines actually return 0 length matches and allow you to step through them using "find next".

In cases like that using your string:
Code:
<p> this is a line of text </p>
The first "match" would be a zero-length match ('<')
Hitting Find again would match 'p'.
Hitting Find again would be a zero-length match ('>')
Hitting Find again would be a zero-length match (the space)
Hitting Find one more time would match 'this'
etc...

Sigil's regex search feature has never "advanced" beyond the first zero-length match to my knowledge. And I don't see any compelling reasons to make it do so. Having to hit "Find" two, three (or more) times before you find a "real" match doesn't seem all that useful or intuitive to me.
KevinH is offline   Reply With Quote
Old 02-17-2018, 02:29 PM   #33
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by DiapDealer View Post
Because his cursor was likely at the beginning of a line of code. I'm sure he'll be able to verify that [a-zA-Z]* does indeed return matches for him when the cursor is placed in front of letter before clicking "Find" (and Minimum Match is unchecked).
I indeed placed the cursor immediately before <?xml version="1.0" encoding="utf-8"?> when I ran my tests and didn't get any matches.

@WS64: Try the following:

1. Create a new epub2 book.
2. Position your cursor immediately before the x in xml in the first line and run your search in Regex mode with all search options unchecked and Down as the search direction. You should get xml as the only match unless you add a space after the asterisk, in which case you'll get a couple more matches.

The search will fail if the cursor is positioned before a non-letter or if a word is highlighted in Code View.

Last edited by Doitsu; 02-17-2018 at 02:36 PM.
Doitsu is offline   Reply With Quote
Old 02-17-2018, 02:36 PM   #34
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: 27,463
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by WS64 View Post
I uploaded a short video.
First with Minimal Matchm then without.
First search for *, then for +
And * never finds anything.

It's hard to read, but maybe it helps anyway: https://www.youtube.com/watch?v=hOtE...ature=youtu.be
Your video indicates that you are using the "Count" button and not the "Find" button as the rest of us are discussing. So there's that. If you place the cursor in front of letters and click "Find" it will highlight what it matches (and it will match something so long as Minimal Match is unchecked).

"Count" will never work when using a zero or more expression because Sigil does not recognize zero-length matches as matches. Never has. So it will stop after the first zero-length match encountered. And since "Count" always starts at the very beginning of a file (and not from where the cursor is placed), the first match of [a-zA-Z]* count will always be zero length.

Last edited by DiapDealer; 02-17-2018 at 02:57 PM.
DiapDealer is offline   Reply With Quote
Old 02-17-2018, 02:49 PM   #35
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: 27,463
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Any search for words that returns non-words as matches is not useful.
Or a search for letters that returns non-letters as matches....
Or a search for numbers that returns non-numbers as matches ...

Regex purists may kick up their heels a bit, but they'll know deep down that from a practical standpoint, those kinds of (non)matches aren't useful 99 times out of 100.

If you want to count occurrences of a repeating pattern in a string, or file, or files, use an expression that looks for one or more repetitions, not zero or more.
DiapDealer is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search is a regex?? drawson1 Library Management 4 12-21-2017 09:57 PM
Regex in search problems (NOT Search&Replace; the search bar) lairdb Calibre 3 03-15-2017 07:10 PM
Regex Search doesn't search all files in Edit Book GregTheGrate Editor 8 11-08-2016 12:47 AM
Why didn't this regex work right? mrmikel Editor 1 04-12-2014 10:04 AM
Search & Replace doesn't work for quotes habanr Conversion 11 04-22-2011 11:50 AM


All times are GMT -4. The time now is 03:23 PM.


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