<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Facades\Log; class XKeywordsUtil { public static function match($C3P5b, $rFmqf, &$sz0Jq = null) { goto QsEWF; QsEWF: $C3P5b = trim($C3P5b); goto KD37O; Ikqu2: $ddUyu = explode(',', $C3P5b); goto sipKr; sipKr: foreach ($ddUyu as $El_MH) { if (empty($El_MH)) { continue; } if (false !== strpos($rFmqf, $El_MH)) { $sz0Jq = $El_MH; return true; } else { if (substr($El_MH, 0, 1) === '@') { if (@preg_match('/' . substr($El_MH, 1) . '/', $rFmqf)) { $sz0Jq = $El_MH; return true; } } else { if (false !== strpos($El_MH, ' ')) { goto h8HmM; h8HmM: $eK2k5 = true; goto theKH; theKH: foreach (explode(' ', $El_MH) as $kh68j) { if (false === strpos($rFmqf, $kh68j)) { $eK2k5 = false; break; } } goto bdSgc; bdSgc: if ($eK2k5) { $sz0Jq = $El_MH; return true; } goto x3pTf; x3pTf: } else { if (preg_match('/((\\*)(\\d+))[^\\d]/', $El_MH, $i5sAZ)) { goto pz5oT; pz5oT: $xM0xW = explode($i5sAZ[1], $El_MH); goto Kyq9S; Kyq9S: $Sv9Jg = '/' . preg_quote($xM0xW[0]) . '.{3,' . $i5sAZ[3] * 3 . '}' . preg_quote($xM0xW[1]) . '/'; goto DjXFW; DjXFW: if (@preg_match($Sv9Jg, $rFmqf)) { $sz0Jq = $El_MH; return true; } goto tqQJn; tqQJn: } else { if (false !== strpos($El_MH, '*')) { goto ErdOn; twI36: if (@preg_match($Sv9Jg, $rFmqf)) { $sz0Jq = $El_MH; return true; } goto SNDcb; XKO2E: $Sv9Jg = '/' . preg_quote($xM0xW[0]) . '.+' . preg_quote($xM0xW[1]) . '/'; goto twI36; ErdOn: $xM0xW = explode('*', $El_MH); goto XKO2E; SNDcb: } } } } } } goto knHey; KD37O: if (empty($C3P5b) || empty($rFmqf)) { return false; } goto Ikqu2; knHey: return false; goto Wg5ZN; Wg5ZN: } public static function description() { $MLXrV = '正则类型
- 简单包含匹配: "你好" 匹配 "你好"多条使用,分割
- 同时包含匹配: "你 好" 匹配 "你们好"、"你们好"、"很好你们"
- 广泛包含匹配: "你*好" 匹配 "你们好"、"你们很好"，*匹配一个或多个
- 限制匹配: "你*1好" 匹配 "你们好"，不能匹配"你们很好"，数字表示最长多少个汉字字符，1个汉字=3英文字母
- 标准正则："@正则表达式" 匹配 "正则表达式"，@开头表示正则表达式
使用说明
- 多个正则使用半角逗号,分割'; return $MLXrV; } public static function test() { goto vxlsT; ZOgtn: return join('
', $DjVjC); goto SKtYh; B_gpV: $DjVjC = array(); goto EuVtZ; EuVtZ: for ($eQWJY = 0; $eQWJY < count($QsWtf); $eQWJY += 2) { $DjVjC[] = sprintf('%-10s%-20s%s', $QsWtf[$eQWJY], $QsWtf[$eQWJY + 1], json_encode(self::match($QsWtf[$eQWJY], $QsWtf[$eQWJY + 1]))); } goto ZOgtn; vxlsT: $QsWtf = array('你好', '你好', '你好', '你们好', '你 好', '你们好', '你*好', '你们好', '你*1好', '你们好', '你*1好', '你们很好', '你*2好', '你们很好', '@你们', '你们很好', '@你好', '你们很好'); goto B_gpV; SKtYh: } }