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-06-2018, 04:02 AM   #1
Wasserpulle
Junior Member
Wasserpulle began at the beginning.
 
Wasserpulle's Avatar
 
Posts: 6
Karma: 10
Join Date: Dec 2013
Location: Europe
Device: Mediapad M3
Thumbs up Regex Search Repetition doesn't work?!

In the past I was using repetition searches like
Code:
[a-zA-Z]*
[0-9]{1,}
quite often using Sigil running on a Windows 7 machine. Recently I changed to a Windows 10 machine and suddenly those searches don't work anymore?
I've tested with several patterns like
{0,}, which is the same as * --> now finds nothing
{1,} being the same as + --> now finds exactly 1 character
{2,4} --> now finds exactly 2 and not the expected 2..4 characters
So it behaves completely strange and only finds the number of characters before the Comma, but no range...

In the first step I suspected Sigil and installed the previous version 0.9.8 in parallel (yes, that works, even it requires some renaming of folders), but it showed exactly the same behavior.

As far as I've seen regex is handled by the PCRE engine, but that doesn't seem to be dependent from Java versions etc, right?
Any idea where to look at?

Thanks for any hint!

Last edited by Wasserpulle; 02-09-2018 at 04:25 AM. Reason: problem solved
Wasserpulle is offline   Reply With Quote
Old 02-06-2018, 08:07 AM   #2
KevinH
Wizard
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: 3,073
Karma: 1931746
Join Date: Nov 2009
Device: many
Perhaps some other app on Windows 10 has a different or broken pcre library someplace in your path?
KevinH is offline   Reply With Quote
Advert
Old 02-06-2018, 09:22 AM   #3
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: 19,019
Karma: 97915638
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
With PCRE being statically built and linked into the Windows Sigil binary, is that even possible?

I'm assuming, of course that the OP is using the official released version of Sigil and hasn't custom compiled Sigil using system libraries.
DiapDealer is offline   Reply With Quote
Old 02-06-2018, 10:21 AM   #4
Doitsu
Wizard
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: 4,279
Karma: 14242649
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
Perhaps some other app on Windows 10 has a different or broken pcre library someplace in your path?
I've just tested [a-zA-Z]* on my Windows and Linux machines and didn't get any matches either. However, [a-zA-Z]+ worked. Does [a-zA-Z]* work on your Mac?

[0-9]{1,} works on my Windows and Linux machines.

Edit: The regex works, but only if the cursor is positioned before a letter.

Last edited by Doitsu; 02-17-2018 at 02:31 PM.
Doitsu is offline   Reply With Quote
Old 02-06-2018, 10:33 AM   #5
Wasserpulle
Junior Member
Wasserpulle began at the beginning.
 
Wasserpulle's Avatar
 
Posts: 6
Karma: 10
Join Date: Dec 2013
Location: Europe
Device: Mediapad M3
Quote:
Originally Posted by DiapDealer View Post
I'm assuming, of course that the OP is using the official released version of Sigil and hasn't custom compiled Sigil using system libraries.
Indeed I got the official release 0.9.9, didn't even try to compile it myself (since years I'm just a stupid user of the extremely good Sigil).
I don't have anything using a PCRE lib in my path. Well, there is one other program, but after installing it hasn't even started yet.

But there seems to be another problem if Doitsu is having a similar issue, even it is just a subset of mine?
Wasserpulle is offline   Reply With Quote
Advert
Old 02-06-2018, 01:08 PM   #6
KevinH
Wizard
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: 3,073
Karma: 1931746
Join Date: Nov 2009
Device: many
Tried the following on a Mac and it worked exactly as expected:

Code:
The regular expression used:
an:\s[a-zA-Z]*
Code:
The file to search in:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>huh</title>
</head>
<body>
<p>&nbsp;There is an: B C 1 2 3</p>
<p>&nbsp;There is an: 1 2 3</p>
</body>
</html>
It first highlighted the "an: B" and then next highlighted the "an: " since we specified the * which allows 0 occurrences of the [a-zA-z] set.

So regular expressions seem to work just fine on a Mac.

Would someone with access to Windows please try this exact example and let me know if it works correctly or not.

Last edited by KevinH; 02-06-2018 at 01:27 PM.
KevinH is offline   Reply With Quote
Old 02-06-2018, 01:13 PM   #7
KevinH
Wizard
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: 3,073
Karma: 1931746
Join Date: Nov 2009
Device: many
Shouldn't be possible if statically linked.
But then I am out of ideas. A locale issue?

Quote:
Originally Posted by DiapDealer View Post
With PCRE being statically built and linked into the Windows Sigil binary, is that even possible?

I'm assuming, of course that the OP is using the official released version of Sigil and hasn't custom compiled Sigil using system libraries.
KevinH is offline   Reply With Quote
Old 02-06-2018, 01:15 PM   #8
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: 19,019
Karma: 97915638
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'll do some testing when I get home.

I haven't looked at the config for the bundled PCRE in a long, long time, so I can't remember if there's differences in how it's configured on Mac vs Win/Lin. I do know that nothing has changed on the bundled PCRE front for a very long time, though.

EDIT: I guess I made a very minor change two years ago to clean up some Windows compiler warnings, but I really can't imagine that being the issue. I'll certainly check to make sure, though.

Last edited by DiapDealer; 02-06-2018 at 01:28 PM.
DiapDealer is offline   Reply With Quote
Old 02-06-2018, 01:26 PM   #9
KevinH
Wizard
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: 3,073
Karma: 1931746
Join Date: Nov 2009
Device: many
Tried the following on a Mac and it worked just fine (ie. it was greedy as expected)
Code:
regular expression was
3{2,4}
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<p>&nbsp;</p>
p>&nbsp;There is an: B C 1 2 3</p>
<p>&nbsp;There is an: 1 2 333</p>
</body>
</html>
It it properly found the 333 which is what I expected. So min and max match counts work properly on a Mac as well.

Would someone please try this on Windows and let me know if it works correctly or not.

Last edited by KevinH; 02-06-2018 at 03:50 PM.
KevinH is offline   Reply With Quote
Old 02-06-2018, 02:08 PM   #10
Wasserpulle
Junior Member
Wasserpulle began at the beginning.
 
Wasserpulle's Avatar
 
Posts: 6
Karma: 10
Join Date: Dec 2013
Location: Europe
Device: Mediapad M3
Quote:
Originally Posted by KevinH View Post
Code:
regular expression was
3{2,4}
Tried that search with your XML code (btw you missed the < in the beginning) under Windows and did the search again, of course enabled regex.
Result: found exactly the first "33" of the string "333".

Looking forward to the results of DiapDealer.
Wasserpulle is offline   Reply With Quote
Old 02-06-2018, 02:23 PM   #11
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: 19,019
Karma: 97915638
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
* + and {min, max} repetition should all be greedy by default. Are certain you're adding or changing nothing in an attempt to affect the default greediness of Kevin's tests?
DiapDealer is offline   Reply With Quote
Old 02-06-2018, 02:27 PM   #12
Doitsu
Wizard
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: 4,279
Karma: 14242649
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
It it properly found the 333 which is what I expected. So min and max match counts work properly on a Mac as well.

Would someone please try this on Windows and let me know if it works correctly or not.
I wasn't able to reproduce Wasserpulle's result. On my Linux and Windows 10 machines 3{2,4} matched 333 not 33.
Doitsu is offline   Reply With Quote
Old 02-06-2018, 03:19 PM   #13
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: 19,019
Karma: 97915638
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I get the same (and expected) results as KevinH and Doitsu on Windows 10.

@Wasserpulle: I'm guessing if Kevin's second test is only matching "33" for you, that you have the Minimal Match option checked. That overrides PCRE's default greediness behavior (including the greediness of repetition). If you uncheck it, you should get the same results as us.

That could also easily explain the results you describe in the very first post.

With the cursor in front of a string of alpha characters, [a-zA-Z]* isn't going to match anything when Minimum Match is checked. Because the minimum match of an expression that's allowed to return nothing will always be nothing.

{1,} should only match the first occurrence if Minimal Match is checked.

Same with {2,4}. With Minimal Match checked, it will never match anything other than the first two occurrences of the criteria.

3{2,4} with Minimum Match checked is essentially the same as searching for "33" -- which is why that's what it matches for you.

Last edited by DiapDealer; 02-06-2018 at 06:30 PM.
DiapDealer is offline   Reply With Quote
Old 02-06-2018, 03:52 PM   #14
KevinH
Wizard
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: 3,073
Karma: 1931746
Join Date: Nov 2009
Device: many
Quote:
(btw you missed the < in the beginning)
Yes, thanks. Copy/Paste error - fixed the code by adding back in the < before the xmlheader line.

Last edited by KevinH; 02-06-2018 at 03:55 PM.
KevinH is offline   Reply With Quote
Old 02-06-2018, 05:55 PM   #15
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,480
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
It is probably a locale issue. Try a semicolon instead, so: {1;2}
Toxaris 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 07:01 PM.


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