Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 04-05-2014, 03:29 AM   #1
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
An introduction to regular expressions - a small advise

Hi!

I just had a look at the sticky thread mentioned in the subject and I think it should be quite useful for starters.

I just like to add one small advise:

Quote:
For ignoring case, the flag is "i", thus you include "(?i)" in your expression. Thus,
Code:
Code:
test(?i)
would match "Test", "tEst", "TEst" and any case variation you could think of.
I'm not a python programmer, but I'm using perl for almost 20 years now and I'd like to draw your attention to the fact that (?flag) in perl is taking effect from the place where you put the flag up to the end of the surrounding group. So that regexp would only match "test" but not "Test" or "TEST".

Well, you may object, in python it's different and in fact http://www.pythonregex.com/ suggests so.

Nevertheless I'd strongly advise to not put the flags anywhere in the regexp, but just at the beginning. This will make things much easier and additionally, follows the python regular expression documentation which states:

Quote:
Note that the (?x) flag changes how the expression is parsed. It should be used first in the expression string, or after one or more whitespace characters. If there are non-whitespace characters before the flag, the results are undefined.
So instead of
Code:
test(?i)
better use
Code:
(?i)test
Skeeve is offline   Reply With Quote
Old 04-05-2014, 11:49 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
If you had read just a little further down, Manichean stated at the Beginning or at the End.

Me, I do it at the beginning
theducks is offline   Reply With Quote
Old 04-05-2014, 05:06 PM   #3
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
Quote:
Originally Posted by theducks View Post
If you had read just a little further down, Manichean stated at the Beginning or at the End.
I'd like to point out that "at the end" is not compatible to the python instructions.
Skeeve is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions Help lauralein Library Management 1 11-12-2013 07:05 PM
Help with regular expressions jevonbrady Library Management 6 06-21-2011 10:16 AM
An introduction to regular expressions Manichean Conversion 0 01-26-2011 05:05 PM
Regular expressions, Calibre and you- an introduction (Archived) Manichean Conversion 80 11-11-2010 07:37 AM
Help with Regular Expressions ghostyjack Workshop 2 01-08-2010 11:04 AM


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


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