- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
<分区>
我试图根据操作系统将用户重定向到不同的页面,但不断收到此警告:
PHP 警告:preg_match() [function.preg-match]:第 292 行/index.php 中的未知修饰符“2”
它似乎只发生在 Windows NT 5.1 和 MSIE 8.0 浏览器配置中:
function getOS($userAgent) {
// Create list of operating systems with operating system name as array key
$oses = array (
'iPhone' => '(iPhone)',
'iPad' => 'iPad',
'Android' => 'Android',
'Windows 3.11' => 'Win16',
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', // Use regular expressions as value to identify operating system
'Windows 98' => '(Windows 98)|(Win98)',
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
'Windows 2003' => '(Windows NT 5.2)',
'Windows Vista' => '(Windows NT 6.0)|(Windows Vista)',
'Windows 7' => '(Windows NT 6.1)|(Windows 7)',
'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
'Windows ME' => 'Windows ME',
'Blackberry' => 'Blackberry',
'Open BSD'=>'OpenBSD',
'Sun OS'=>'SunOS',
'Linux'=>'(Linux)|(X11)',
'Macintosh'=>'(Mac_PowerPC)|(Macintosh)',
'QNX'=>'QNX',
'BeOS'=>'BeOS',
'OS/2'=>'OS/2',
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)'
);
//'Safari' => '(Safari)',
foreach($oses as $os=>$pattern){ // Loop through $oses array
// Use regular expressions to check operating system type
if(preg_match("/".$pattern."/i", $userAgent)) {
// Check if a value in $oses array matches current
//user agent. <---- Line 292
尝试删除 OS/2 并更改为 OS2,但仍然重定向到带有 Windows XP 的 MSIE 8 的错误页面
我想知道我们是否可以替换 if(preg_match('/boo/', $anything) 和 preg_match('/poo/', $anything)) 用正则表达式.. $anything
假设字符串是: $a = "abc-def" if (preg_match("/[^a-z0-9]/i", $a, $m)){ $i = "i stopped scanning '$a' beca
好的,所以我希望用户能够输入 A-Z 中的每个字符和 0-9 中的每个数字,但我不希望他们输入“特殊字符”。 代码: if (preg_match("/^[a-zA-Z0-9]$/", $user_n
我想使用 preg_match 来查找括号之间的文本,例如:$varx = "(xx)"; 最终输出将是 $match = 'xx'; 另一个例子$varx = "bla bla (yy) bla b
嘿伙计们,我正在尝试删除最后一个 _1.jpg 如果它存在于我的表达中,但我遇到了一些麻烦 场景如下。 image_name_1.jpg(应该是image_name.jpg) image_name_1
我需要修复这个 preg_match("/^[[0-9]{0,4}$/i", $input),它还需要接受负值。谢谢 最佳答案 if (preg_match('/^-?[0-9]{1,4}$/', $
我正在尝试提出一个符合 25 的正则表达式在这个字符串中: Always - 25 (Lifetime - 之间的空间量和 25可以是可变的,但尾随 (Lifetime将永远在
我试图通过仅过滤掉符合以下条件的单词来匹配字符串中的关键字: 任何地方都有大写字母的单词,例如“iPhone”或“camelCase” 连续大写的词组,例如“Pittsburgh Steelers”或
我在 mysql 字段中有此数据: First text text text text text text text text text text text text text text tex
我有这个代码 preg_match("/\bHTTP(.)+ (\d{3})/", $string) 在最后一个模式中,我必须检查一个可以由任何数字组成但不应该创建像 404 或 401 这样的数字的
你好,我想匹配下一行中的“@”, create@create_time:"2012-05-30 21:14:35.0",update_time:"2012-05-31 22:05:46.0" preg
我使用“或”运算符“|”只匹配 $name 变量的单词 $name = "one five six two"; if (preg_match('/(one|two)/i', $name)) {retu
大家好 我有一个字符串 Open Directory Sites (1-20 of 10000) 我需要得到 10000 作为答案.. 我如何使用 preg_match ???注意:这是重要的,匹配的
我想使用 preg_match 为带括号的子模式返回每个匹配项的数组。 我有这个代码: $input = '[one][two][three]'; if ( preg_match('/
我有一个像这样值的变量: $sentence = "When it comes time to renew your auto insurance policy, be aware of how yo
我只想允许使用字母、数字、空格、无色线和连字符。 到目前为止,我认为这个 preg_match 可以完成这项工作: if(preg_match('/[^a-z0-9 _]+$/i', $name))
这个问题与this直接相关我大约 15 分钟前提出的问题。这不是要与那个帖子重复,而是希望这更多是一种学习经验。 在提出的问题中,我试图找出导致 preg_match no deliminator f
我有以下字符串 № покупки(OrderId) : 12345 Доп.Информация 1 : Имя Доп.Информация 2 : Уставная деятельность 我
我正在尝试为我们的防火墙创建报告功能。 防火墙规则以 json 格式存储。 这是字符串的示例。 [{"id":1,"enabled":true,"description":"TEMP","matche
在多个模式的情况下,可以在相同的数组索引下返回 preg_match 的结果。我的意思是我有以下 preg_match 什么正在检查不同子字符串( '&q' 、 '?q' 、 '&keywords'
我是一名优秀的程序员,十分优秀!