You are here: PSPad forum > Bug report / Hlášení chyb > [BUG] Non-greedy regexp is greedy

[BUG] Non-greedy regexp is greedy

#1 [BUG] Non-greedy regexp is greedy

Posted by: SanskritFritz | Date: 11/12/2008 16:04 | IP: IP Logged

This is the search expression:
-.*?/
This is where i preform the search:
CC-3623843-4/2008
I expected PSPAd to find
-4/
but it only finds
-3623843-4/

Edited 1 time(s). Last edit at 11/12/2008 16:05 by SanskritFritz.

Options: Reply | Quote | Up ^


#2 Re: [BUG] Non-greedy regexp is greedy

Posted by: vbr | Date: 11/12/2008 16:59 | IP: IP Logged

SanskritFritz:
This is the search expression:
-.*?/
This is where i preform the search:
CC-3623843-4/2008
I expected PSPAd to find
-4/
but it only finds
-3623843-4/

I belive, this is a standard behaviour, which you also get in other re engines (I just checked python and javascript). The search is performed left-to-right, the backtracking is only used if there is no match reached.

Can you maybe provide a sample of data and what should be matched? (maybe the pattern could be adopted).
You can e.g. use the following to get the wanted effect:
-[^-]*?/
or some other pattern.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2013 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák