[Pmwiki-users] Another interlink-pattern issue

Patrick R. Michaud pmichaud
Sat Jan 10 21:43:37 CST 2004


On Sun, Jan 11, 2004 at 02:46:26PM +1300, Robin Sheat wrote:
> On Sun, Jan 11, 2004 at 01:21:06AM +0100, Christian Ridderstr?m wrote:
> > I know :-( I've been trying to define a pattern for a path that allows '.'
> > but not '..'. In the end I decided to work around it in another way. It's
> > kind of strange that regexps don't (AFAIK) have a 'not' operator.
>
> OK, I'm still hunover from catching up with friends last night, so this
> may be completly off the mark, but something like:
> \.[^\.]

Doesn't work.  This pattern says the string must contain a dot followed by
a character that is not a dot.  This would successfully match the string
"hello..world", which has two consecutive dots in it.  (The pattern would 
successfully match the ".w" portion of the string--a dot followed by
a non-dot.)

You can try to do something like 

  ^[^.]*(\.[^.]+)*\.?*$

which says that any dot in the string has to be followed by a character
that's not a dot (or the end of the string), but things start to get
nastier when you try to keep from doubling other characters as well
(you have to start using backreferences and the like), and you have to
work a bit to get rid of the string anchors and still get what you want.

Pm



More information about the pmwiki-users mailing list