略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: sql_regcase

2024-04-19

sql_regcase

(PHP 4, PHP 5)

sql_regcase产生用于不区分大小的匹配的正则表达式

说明

sql_regcase ( string $string ) : string

产生用于不区分大小的匹配的正则表达式

Warning

自 PHP 5.3.0 起,已经废弃此函数。强烈建议不要应用此函数 。

参数

string

输入的字符。

返回值

返回与 string 相匹配的正则表达式,不论大小写字母。返回的表达式是将 string 中的每个字母字符转换为方括号表达式,该方括号表达式包含了该字母的大小写形式。其它字符保留不变。

范例

Example #1 sql_regcase() 例子

<?php
echo sql_regcase("Foo - bar.");
?>

以上例程会输出:

[Ff][Oo][Oo] - [Bb][Aa][Rr].

可以用于在仅支持区分大小写正则表达式的产品中完成不区分大小写的模式匹配。

注释

Note:

在 PHP 5.3.0 中,已放弃使用 regex 扩展而建议使用 PCRE 扩展。调用此函数将会发出 E_DEPRECATED 通知。参见“差异列表”可帮助你转为使用 PCRE。

add a note add a note

User Contributed Notes 2 notes

up
-1
edge at gts dot smtn dot stavropol dot ru
15 years ago
if you set right locale:

setlocale(LC_CTYPE,"ru_RU.KOI8-R");

print sql_regcase("Цffnung");

will output:
"[Цц][Ff][Ff][Nn][Uu][Nn][Gg]"
up
-3
phpcomment at revmaps dot no-ip dot biz
5 years ago
This function naivley replaces the letters in your expression.
if your expression uses [] already using this will probably break it

官方地址:https://www.php.net/manual/en/function.sql-regcase.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3