Web Analytics Made Easy -
StatCounter Regular Expressions (preg_match) - CodingForum

Announcement

Collapse
No announcement yet.

Regular Expressions (preg_match)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regular Expressions (preg_match)

    If you can define how something starts using preg_match, can you define what character(s) something ends with.

    For example, the following would have to start with an upper-case letter.
    PHP Code:
    /^[A-Z][a-zA-Z]$/ 
    If I'm building a random password generator can I use the same syntax as above to define the characters in the password?
    Last edited by stevenmw; Aug 18, 2011, 04:33 AM.
    Thanks!

  • #2
    You can match the end of string using $. Check this tutorial for more details.
    The random password generator should choose characters from one or more predefined strings (e.g. "abcdef" "ABCDEF" "1234567890" "abcdefABCDEF1234567890") according to your passwords policy rules (num of lower, num of caps, num of numbers, etc).
    Last edited by gvre; Aug 18, 2011, 04:49 AM.

    Comment

    Working...
    X