我想删除字符串中的word
:
Word , WOrd , WORd , wORd , word , WoRd
我研究过它,但找不到实现这个目标的方法。如何为此编写正则表达式?
答案 0 :(得分:1)
请参阅PHP manual
中的以下示例<?php
// The "i" after the pattern delimiter indicates a case-insensitive search
if (preg_match("/php/i", "PHP is the web scripting language of choice.")) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
?>
答案 1 :(得分:0)
使用/i
修饰符忽略大小写。
$input = preg_replace("/word/i", "", $input);
答案 2 :(得分:0)
可能不是你想要的但是这里......
$words = "Word , WOrd , WORd , wORd , word , WoRd";
$wordArray = explode(",", $words);
foreach($wordArray as $key=>$word){
if($word==strtolower($word)){
unset($wordArray[$key]);
}
}