[請益] 看不懂preg_replace函數的使用範例

看板PHP作者 (sob)時間17年前 (2006/12/15 19:51), 編輯推噓3(303)
留言6則, 2人參與, 最新討論串1/19 (看更多)
下例傳回值為 $startDate = 6/19/1969 <?php $patterns = array("/(19|20\d{2})-(\d{1,2})-(\d{1,2})/", "/^\s*{(\w+)}\s*=/"); $replace = array("\\3/\\4/\\1", "$\\1 ="); print preg_replace($patterns, $replace, "{startDate} = 1969-6-19"); ?> 這是我在google搜preg_replace函數的使用方法 但我怎麼看$patterns和$replace也沒辦法推測出像答案一樣的結果 我的問題應該是卡在許多符號看不懂其代表的意思 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.142.122

12/15 20:02, , 1F

12/15 20:02, , 2F
建議 google://regexp regular expression 正規表示式
12/15 20:02, 2F



12/15 20:22, , 5F
天阿!好複雜的東西,研究去,感謝
12/15 20:22, 5F

12/15 20:45, , 6F
威力強大的工具 :)
12/15 20:45, 6F
文章代碼(AID): #15WemhHr (PHP)
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 19 篇):
文章代碼(AID): #15WemhHr (PHP)