I have an expression that I want to modify. This ex开发者_JAVA百科pression, for the most part does what I want, however, I need to to also match for case insensitive.
I am matching names of people as well as business names. So, the following should be matched and currently is not:
tim's baKeRY
Here is the expression
#^[A-Z][a-z]+[ -][A-Z](\')?(?(1)[A-Z])[a-z]+$#
EDIT
Thanks to Gustav, I edited my expression to:
#^[a-zA-Z]+[ -][a-zA-Z](\')?(?(1)[a-zA-Z])[a-z]+$#
This gives me case insensitivity which was part of what I needed but I also need to match something like tim's bakery
You can do /.../i
in PHP to match case insensitive. If you want to correct what you have though, you need to observe that [A-Z][a-z]+
will match one initial capital letter and then the rest lower case. If you want to match both in the same, you need to do [A-Za-z]+
.
Hope that helps!
精彩评论