Heim >Backend-Entwicklung >PHP-Tutorial >这个正则怎么写

这个正则怎么写

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:48:20981Durchsuche

 我要取出表名。


回复讨论(解决方案)

这个数组里些是创建表的sql语句,然后我想要获取到表名,帮写个正则 - -

<?php$array = array("CREATE TABLE `order_log_1` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))",    "CREATE TABLE `order_log_2` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))",    "CREATE TABLE `order_log_3` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))",);$pattern = '/CREATE TABLE `(\w+)`/i';foreach ($array as $item) {    if (preg_match($pattern, $item, $match)) {        var_dump($match[1]);    }}?>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn