Case insensitive for the regex part?

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

Example:

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

Voicemail should be case-insensitive, but the other half should obviously be case-sensitive, as it searches for the first name + surname, with the first letter capitalized in each.

So if i do

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

he will not work, because now he will correspond to such things as "Guest post a small dog", which I do not want.

However, it must comply with Brian Williams' GUEST REQUEST.

+4
source share
2 answers

, :

(?i:)

:

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

: http://regex101.com/r/pW1gV9

( @robertodecumex!) , , .

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

Regexp,

/#{/guest post by/i} #{/[A-Z][a-z]+\s[A-Z][a-z]/}/
+1

All Articles