Case insensitive for part of the regex?

Viewed 307

I have a regex where part of the regex should be case insensitive.

Example:

/Guest post by ([A-Z][a-z]+\s[A-Z][a-z]+)/

"Guest post by" should be case insensitive, but the 2nd half obviously needs to be case sensitive as it's looking for a first name + last name, with the first letter capitalized in each.

So if I do

/Guest post by ([A-Z][a-z]+\s[A-Z][a-z]+)/i

it won't work because now it'll match things such as "Guest post by small dog", which I don't want.

However, it needs to match with "GUEST POST BY Brian Williams".

2 Answers
Related