Regex that matches Camel and Pascal Case

ε祈祈猫儿з 提交于 2019-12-04 09:20:35

camelCase:

^[a-z]+(?:[A-Z][a-z]+)*$

PascalCase:

^[A-Z][a-z]+(?:[A-Z][a-z]+)*$
/([A-Z][a-z]+)*[A-Z][a-z]*/

But I have to say your naming choice stinks, HTMLParser should be allowed and preferred.

I don't believe the items listed can start with numbers (thought I read it somewhere so take it with a grain of salt) so the best case would be something like Roger Pate's with a few minor modifications (in my opinion)

/([A-Z][a-z0-9]+)*[A-Z][a-z0-9]*/

Should be something like, Look for a Capital Letter, then at least one small case or number, or more, as well as it looks like it handles just a capital letter as that seems to be required, but the additional letters are optional.

Good luck

^[A-Z][a-z]*([A-Z][a-z]*)

This should work for :

  1. MadeEasy
  2. WonderFul
  3. AndMe

this types of patters.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!