0
length should be [2-10],

should accept [a-zA-z0-9],accept one space in between characters.

eg: timesheet 2
    shanti chakra
    shantichakra
    shantichakra2

Edited by chaitu11

3
Contributors
11
Replies
37
Views
3 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1
    diafol 3,669   3 Years Ago

    WOuld replacing multiple spaces with a single space be any use? $spaced = preg_replace('/ {2,}/', ' ', trim($inputString)); Read More

  • 1

    I got to this: ^[a-zA-Z0-9](?:[a-zA-Z0-9]|[ ](?=[^ ]*$)){0,8}[a-zA-Z0-9]$ Read More

  • 1

    E-mail is dangerous to do with a regex, as it allows for invalid ones to get through. There is no guarantee with such a check. It's much better to send a confirmation link to an e-mail address. Read More

  • 1
    diafol 3,669   3 Years Ago

    There are validation filters available in PHP [http://php.net/manual/en/filter.filters.validate.php](and I assume other languages) which can check email Read More

0
i tried this but how to menstion length{1,10}

^[a-zA-Z0-9](\w+\s?)*$

Edited by chaitu11

1

WOuld replacing multiple spaces with a single space be any use?

$spaced = preg_replace('/ {2,}/', ' ', trim($inputString));
0

The reason I'm asking is do you want to use a preg_replace for simple mistakes like multiple spaces or are you just going for straight unequivocal validation which will spit out anything with a double space?

1

I got to this:

^[a-zA-Z0-9](?:[a-zA-Z0-9]|[ ](?=[^ ]*$)){0,8}[a-zA-Z0-9]$

Edited by pritaeas

0

regular expression for valid email

/^[\w-.+]+\@[a-zA-Z0-9.-]+.[a-zA-z0-9]{2,4}$/;

Edited by chaitu11

1

E-mail is dangerous to do with a regex, as it allows for invalid ones to get through. There is no guarantee with such a check. It's much better to send a confirmation link to an e-mail address.

Edited by pritaeas

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.