Thread: Regex examples
View Single Post
Old 08-08-2014, 04:33 PM   #385
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,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by eschwartz View Post
Never seen \K before.

Seems like it is useful mainly as a replacement for lookbehind assertions (while still capturing stuff! )
Actually, I could be wrong. \K may not be a part of the regex module being used in calibre. I will miss it very much if so.

But then again... with variable-length lookbehind assertions allowed, it may not be all that hard to replicate \K's functionality!

I've just always hated remembering the lookbehind syntax:
When using the string 'hhhhhhhhhhhhhhhhhhhhhhd':
It was always easier to search for h+\Kd in Sigil (provided finding a 'd' that follows a potentially unknown number of 'h's was as vitally important to you as it is to me! ). Beside the fact that (?<=h+)d wouldn't fly in Sigil, the (?<=) and (?<!) hokum of lookbehinds was (and still is) always difficult for me to remember on the fly. I find it terribly unintuitive.

But now that (?<=h+)d WILL work in calibre's editor ... the \K isn't AS vitally important to me--provided I get over the mental stumbling block of remembering the (positive|negative) look(ahead|behind)'s syntax.

So with the exception of the case alteration on replacements, what are you finding you can't do in calibre's regex S&R that you could in Sigil's?

Last edited by DiapDealer; 08-08-2014 at 04:42 PM.
DiapDealer is offline   Reply With Quote