views:

26

answers:

2

I have this regexp:

  var desExp = /^\s*([\wåäö][^\w]*){3}.*$/gm;

This is for validating a textarea.

Currently, you cant use the three Swedish language letters in the beginning.

The letters are å, ä, ö, Å, Ä, Ö.

Also, I would like it to allow the minus sign and the star (multiplication) sign:

- and *

Is there any remake to allow them in the beginning?

They are currently allowed in the middle of texts, and endings...

Here is how I compare:

if (!fld.value.match(desExp)){ 
    //ERROR

Thanks

UPDATE:

The above allows small characters of swedish å ä ö, but not uppercase, and not multiplication-sign and minus-sign, which I still need to work.

Thanks

A: 

This RegExp should work, but you have to set the flag i to allow them upperCase too.

Dr.Molle
Okay, I noticed now that small characters do work. Sorry about that, must have missed it. But how do I set the i to allow uppercase? Also, any way to make it possible to have "stars (multiplication sign)" and "minussign" in beginning also, because that doesn't work.
Camran
How i said, add the flag i . Flags are currently gm at the end of the pattern, append the i. `gmi` . the other chars you have to escape with a backslash when you put them to a RegExp, while they have special meanings in RegExp.
Dr.Molle
A: 

Try

/^\s*([\wåäö*-][^\w]*){3}.*$/gmi;

This should allow uppercase characters as well as * and -.

Tim Pietzcker