Reputation: 167
I have below string pattern
step_User_Save_Action_Details
I want to make sure a capital letter follows after each underscore symbol.
Example:
step_User_Save_Action_Details - Should return true
step_User_save_Action_Details - Should return false
Tried with below pattern but seems to not working...
step[_[A-Z]*]
Upvotes: 2
Views: 312
Reputation: 785156
You can use this regex:
\bstep(?:_[A-Z][A-Za-z]*)+\b
(?:_[A-Z][A-Za-z]*)
makes sure that there is an uppercase letter right after underscore. +
quantifier after this non-capturing group will let it match multiple of these underscores in the word.
\b
is there to enforce word boundary before step
and after last component.
Upvotes: 5