[Pmwiki-users] Another interlink-pattern issue

Christian Ridderström chr
Sun Jan 11 02:57:47 CST 2004


On Sat, 10 Jan 2004, Patrick R. Michaud wrote:

> 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.

Be gentle! He's 'hunover' :-)

>  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.

Oh, I know .. it's a nuisance :-(

This is actually about the modified directive

	[[$Attachlist:<path>]]

that I'm working on. I'll simply solve it by allowing '<path>' to contain 
'..' when matching the entire directive, i.e. something like

	'\\[\\[$Attachlist:(.[^ ])+\\]\\]'

and then if '<path>' contains '..' or other invalid characters I'll 
produce an error message. Actually, this will probably also result in 
faster code since the regexp for finding the directive is less 
complicated.

Finally, I've realized that due to the structure of the Upload area, 
I don't actually need to '../' in the path, i.e.

	[[$Attachlist:../OtherGroup]]

is really the same as:

	[[$Attachlist:/OtherGroup]]

/Christian

-- 
Dr. Christian Ridderstr?m, +46-8-768 39 44       http://www.md.kth.se/~chr




More information about the pmwiki-users mailing list