【发布时间】:2015-10-29 12:42:00
【问题描述】:
我想仅使用 preg_replace 将括号内的逗号 (,) 替换为冒号 (:)
输入:
`parent_id` int(10) unsigned DEFAULT NULL,
`type` enum('text','textarea','mail','uri','date','image','checkbox','menu','menu_option','group','frame','history') NOT NULL DEFAULT 'text',
输出:
`parent_id` int(10) unsigned DEFAULT NULL,
`type` enum('text':'textarea':'mail':'uri':'date':'image':'checkbox':'menu':'menu_option':'group':'frame':'history') NOT NULL DEFAULT 'text',
请给我们建议
【问题讨论】:
-
用“','”替换“':'”不符合您的要求吗?请注意字面的撇号。
-
先捕获"(" ")"之间的整个字符串,然后做你想做的事。
-
但你为什么要这么做?
标签: php regex preg-replace