Jump to content

help with ereg


Karabas

Recommended Posts

After using

 

{
function valid_name($name)
// check ifa name is possibly valid
if(ereg("^[A-Z][A-Za-z\ \-]+$", $name))
return true;
else
return false;
}

 

I want a bit more sophistication:

1) capital characters must be preceeded by space

2) space must be followed by a capital letter

 

I tried replacing A-Z in [A-Za-z\ \-]+ by \ A-Z etc but it failed to function as I want. Thank you very much in advance.

Link to comment
Share on other sites

  • 2 weeks later...

Please replace this with previous code bcoz previous code restricts length of words in name to be more than one.

 

function valid_name($name)
{
   // check if a name is possibly valid
  if(ereg("^[A-Z][a-z-]+([ ]{1}[A-Z]+[a-z-]+)?$", $name))
     return true;
  else
     return false;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.