Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Ereg question

    Greetings,

    I'd like to add somee error handling to a password field: if the
    password is fewer than 5 characters or greater than 15 characters I'd
    like to trap it. Special characters such as ^ and ~ will be allowed, but
    spaces will not be allowed.

    Can someone suggest and ereg expression that will help with this? Also,
    does php have a length function similar to vb's len(mystring)?

    bonehead Guest

  2. Similar Questions and Discussions

    1. ereg problem
      Can any of you kind people tell me what I'm doing wrong? An example: $code="<gateway>FooBar</gateway>"; $var="gateway"; I am trying to get...
    2. ereg
      Hi! I'm working with ereg and mails now. Does represent only A-Z, 0-9 or something more? And if yes, ther what? TIA RuBenz
    3. [PHP] Bug in Ereg?
      ow .. this script won't work .. checkboxes like this: <input type=checkbox name="colors" value="on"> or var calling like this: $_POST ...
    4. Bug in Ereg?
      Hi, I have a form with checkboxes that POSTs to a PHP script. What is posted : _POST on _POST on _POST on
    5. simple ereg() question
      Hi, How do i check with ereg() is a string is non-empty (!== '') Thx G
  3. #2

    Default Re: Ereg question

    Yup, regular expression is the perfect tool for this task. Try this:

    echo preg_match('|^\\w{5,15}$|', $password) ? "Good" : "Bad";

    Uzytkownik "bonehead" <sendmenospam@here.org> napisal w wiadomosci
    news:3FD20296.1070008@here.org...
    > Greetings,
    >
    > I'd like to add somee error handling to a password field: if the
    > password is fewer than 5 characters or greater than 15 characters I'd
    > like to trap it. Special characters such as ^ and ~ will be allowed, but
    > spaces will not be allowed.
    >
    > Can someone suggest and ereg expression that will help with this? Also,
    > does php have a length function similar to vb's len(mystring)?
    >

    Chung Leong Guest

  4. #3

    Default Re: Ereg question

    bonehead wrote:
    > Also, does php have a length function similar to vb's len(mystring)?
    Sure: $length = strlen($mystring);
    <URL: http://no2.php.net/manual/en/function.strlen.php>

    --
    Tormod Fjeldskår
    [email]tormod@fritidsproblemer.no[/email]
    [url]http://tormod.fritidsproblemer.no/[/url]
    Tormod Fjeldskår Guest

  5. #4

    Default Thanks Re: Ereg question

    Chung I must say you've been very very helpful. Sure hope you're getting
    paid enough. And are you actually fluent in Polish?

    Chung Leong wrote:
    > Yup, regular expression is the perfect tool for this task. Try this:
    >
    > echo preg_match('|^\\w{5,15}$|', $password) ? "Good" : "Bad";
    >
    > Uzytkownik "bonehead" <sendmenospam@here.org> napisal w wiadomosci
    > news:3FD20296.1070008@here.org...
    >
    >>Greetings,
    >>
    >>I'd like to add somee error handling to a password field: if the
    >>password is fewer than 5 characters or greater than 15 characters I'd
    >>like to trap it. Special characters such as ^ and ~ will be allowed, but
    >>spaces will not be allowed.
    >>
    >>Can someone suggest and ereg expression that will help with this? Also,
    >>does php have a length function similar to vb's len(mystring)?
    bonehead Guest

  6. #5

    Default Re: Thanks Re: Ereg question

    I get paid well enough for someone who studies Polish :-)

    Uzytkownik "bonehead" <sendmenospam@here.org> napisal w wiadomosci
    news:3FD220FE.30500@here.org...
    > Chung I must say you've been very very helpful. Sure hope you're getting
    > paid enough. And are you actually fluent in Polish?
    >
    > Chung Leong wrote:
    > > Yup, regular expression is the perfect tool for this task. Try this:
    > >
    > > echo preg_match('|^\\w{5,15}$|', $password) ? "Good" : "Bad";
    > >
    > > Uzytkownik "bonehead" <sendmenospam@here.org> napisal w wiadomosci
    > > news:3FD20296.1070008@here.org...
    > >
    > >>Greetings,
    > >>
    > >>I'd like to add somee error handling to a password field: if the
    > >>password is fewer than 5 characters or greater than 15 characters I'd
    > >>like to trap it. Special characters such as ^ and ~ will be allowed, but
    > >>spaces will not be allowed.
    > >>
    > >>Can someone suggest and ereg expression that will help with this? Also,
    > >>does php have a length function similar to vb's len(mystring)?
    >

    Chung Leong Guest

  7. #6

    Default Re: Ereg question

    bonehead wrote:
    >
    > Greetings,
    >
    > I'd like to add somee error handling to a password field: if the
    > password is fewer than 5 characters or greater than 15 characters I'd
    > like to trap it. Special characters such as ^ and ~ will be allowed, but
    > spaces will not be allowed.
    >
    > Can someone suggest and ereg expression that will help with this? Also,
    > does php have a length function similar to vb's len(mystring)?
    The preg functions are usually faster than the ereg. And strlen() will give you
    the string length.

    Shawn
    --
    Shawn Wilson
    [email]shawn@glassgiant.com[/email]
    [url]http://www.glassgiant.com[/url]
    Shawn Wilson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139