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
https://forums.phpfreaks.com/topic/50246-help-with-ereg/
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
https://forums.phpfreaks.com/topic/50246-help-with-ereg/#findComment-255216
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.