Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Web >> Development >> PHP >> How to extract certain patterns of a string using regular expressions

<?php $string = "{home,http://a.b.c/home}"; preg_match("/^[{]([^,]+),(.*)[}]$/",$string,$matches); echo "$matches[1]\n"; echo "$matches[2]\n"; // note that $matches[0] contains the entire string if a match is found and // $matches[1] onwards contains sub-section matches. in this example $matches[1] = "home"; $matches[2] = "http://a.b.c/home" ?>
[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]