Avatar of MattKenefick
MattKenefickFlag for United States of America

asked on 

Regex for First Character Captial , Following letters must be lowercase

I have this pretty much perfect except for a minor bug...

What i got is..

$alb = "An Expression That Follows The Rules";
preg_match("/[0-9A-Z+a-z \.\'-]+[^A-Z0-9][^A-Z]/",$alb,$str);

That works....

However..

when i put like

$alb = "An Expression That Follows The RulesBBOAO";
preg_match("/[0-9A-Z+a-z \.\'-]+[^A-Z0-9][^A-Z]/",$alb,$str);


The BBOAO will come through....
How do I make it stop if theres captials without a space before it...
and also it cant be consecutive capitals


Thanks a ton. it took me forever to write the expression up there, lol im not good with these
PHPJavaScriptPerl

Avatar of undefined
Last Comment
JamesCssl
ASKER CERTIFIED SOLUTION
Avatar of JamesCssl
JamesCssl
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ozo
ozo
Flag of United States of America image

\b[A-Z][a-z]*
Avatar of MattKenefick
MattKenefick
Flag of United States of America image

ASKER

nevermind, i got it



preg_match("/[A-Z0-9a-z \.\'-]+[a-z ]/",$alb,$str);




that did it
Avatar of MattKenefick
MattKenefick
Flag of United States of America image

ASKER

can we close this? thank you!
Avatar of JamesCssl
JamesCssl
Flag of United States of America image

I think you have to ask in Community Support.
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo