[Wylug-help] Javascript Regular expression

Dave Whiteley d.l.whiteley at ee.leeds.ac.uk
Wed May 26 13:00:48 BST 2004


Hello All,

I am puzzled...

I am tinkering with some proprietory software, which is partly
controlled by a web form. This is validated by javascript, and I am
trying to work out what it is expecting.

The code is

function checkMdir(value)
{
	var pattern = /^(((\/\w+(\w+)*)+)((\s((\/\w+(\w+)*)+))*))$/;
	return (pattern.test(value));
}

The value being tested is passed as value.

As I read this it is asking for "slash word" optionally followed
by any number more of the same, separated by single spaces.

It does not seem to be accepting this.

Is it me, or is my browser doing something odd?

When I look at \/\w+(\w+)* I cannot see what the (\w+)* achieves. Is it
not already handled by the + on the first one.

Dave


--

Dave Whiteley
d.l.whiteley at ee.leeds.ac.uk
Phone +44 (0)113 343 2059
School of Electronic and Electrical Engineering
The University of Leeds. Leeds, LS2 9JT,  UK




More information about the Wylug-help mailing list