phdesigner:
--------------------------------------------------------------------------------
if I search for [ ]*(?=[ ]) in PSPad's normal search it says there's an error in
the search expression, however if I search for it with phReplace I find mathces
but some of the matches will have 0 length. I'm not sure what to do with that. I
expected this search to find a space with any trailing spaces (I know there are
better ways to do this, but it's a good example for this 0 length problem)

I'm guessing PSPad first vaildates the search, I don't think vb offers any
support for validating it.

--------------------------------------------------------------------------------


Hi, thanks for taking backreferences into account. - I think, the reason your
expression don't work in PSPad's built in search is simply because it doesn't
support these advanced features at all. I allready noticed this limitation - 

 - this is called "positive lookahead" 
see my favourite ressource
http://www.regular-expressions.info/lookaround.html
(i noticed that your script supports also the negative lookahead, but it doesn't
support the Lookbehind constructions - here I get a run-time error 5017
application-defined or object-defined error; but after closing a dialog with the
upper right cross (not Close) other searches work ok; I think this is enough to
see an error; the validator would probably complicate the code a bit)


your expression [ ]*(?=[ ]) should match zero or more spaces only if it is/they
are followed by a space.



the lookahead expression (?=[ ]) isn't part of the match it is only used as a
condition if the preceeding part should match. As [ ]* can be zero width, the
same is true for the whole expression.

(if you have a single space in the source text, the "zero times space" is
matched and the space itself is taken as necessary condition for this match)

[ ]* - alone would also match each zero width "nothing" between all characters

What specifically should be matched in this case?

"a space with any trailing spaces"

" +" (without quotes) would match one or more spaces (the [] aren't necessary as
there is only one character).

-- 
<http://forum.pspad.com/read.php?2,34061,38044>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem