preg_match("#(.{100}$keywords.{100})#", strip_tags($description), $matches);
I'm trying to show only 100 characters in each side with the search string in the middle.
我尝试在每条边显示100个字符,中间是搜索字符串。
This code actually works but it is a case sensitive, how do i make it case insensitive?
这个代码实际上是有效的,但它是区分大小写的,我如何使它不区分大小写?
1 个解决方案
#1
73
Just add the i
modifier after your delimiter #
:
只需在分隔符#后面添加i修饰符:
preg_match("#(.{100}$keywords.{100})#i", strip_tags($description), $matches);
If the i
modifier is set, letters in the pattern match both upper and lower case letters.
如果设置了i修饰符,则模式中的字母将同时匹配大小写字母。
#1
73
Just add the i
modifier after your delimiter #
:
只需在分隔符#后面添加i修饰符:
preg_match("#(.{100}$keywords.{100})#i", strip_tags($description), $matches);
If the i
modifier is set, letters in the pattern match both upper and lower case letters.
如果设置了i修饰符,则模式中的字母将同时匹配大小写字母。