views:

67

answers:

3

1) ^[^\s].{1,20}$

2) ^[-/@#&$*\w\s]+$

3) ^([\w]{3})$

Are there any links for more information?

+1  A: 

1) match everything without space what have 1 to 20 chars.

2) match all this signs -/@#&$* plus words and spaces, at last one char must be

3) match three words

here is excelent source of regex

http://www.regular-expressions.info/

Dobiatowski
For "word" read "a character that is considered to be part of a word"; specifically, a letter, number, or underscore. Also worth noting that the ^ and $ indicate that each of the expressions is anchored to the beginning and ending of the line; it won't match just a part of a line.
JacobM
\w is not matching words. 3) matches three symbls of type letter, digit or underscore !to test your regexp you an use this tool:http://rexv.org/Edit: JacobM was faster :)
budinov.com
Also, "3)" contains a capturing group for the three word pattern
FK82
1) is incorrect here. It will match something that doesn't start with a space, which is followed by between 1 and 20 other characters except newlines.
Andy E
+1  A: 
  1. Matches any string that starts with a non-whitespace character that's followed by at least one and up to 20 other characters before the end of the string.

  2. Matches any string that contains one or more "word" characters (letters etc), whitespace characters, or any of "-/@#&$*"

  3. Matches a string with exactly 3 "word" characters

Pointy
+8  A: 
^[^\s].{1,20}$

Matches any non-white-space character followed by between 1 and 20 characters. [^\s] could be replaced with \S.

^[-/@#&$*\w\s]+$

Matches 1 or more occurances of any of these characters: -/@#&$*, plus any word character (A-Ba-b0-9_) plus any white-space character.

^([\w]{3})$

Matches three word characters (A-Ba-b0-9_). This regular expression forms a group (with (...)), which is quite pointless because the group will always equal the aggregate match. Note that the [...] is redundant -- might as well just use \w without wrapping it in a character class.

More info: "Regular Expression Basic Syntax Reference"

J-P
+1 I had barely gotten through parsing number one in the time it took you to do this, I really need to work on my regex :/
kekekela
\w means [a-zA-Z0-9_]
M42