PHP REgEx preg_replace first folder name (wildcard)

azazaz

New Member
Having regex issues..I have a series of directories that hold .htm templates... all template packs are held in folder tpl/ (not really that important)tpl contains a default template pack called tpl_default.I am writing a function that reads from the current template file and then gets all Tokens {TOKEN} from the same file in the default directory.\[code\]// $file returns abundant/index/index.htm as an example. So need to change that to read tpl_default/index/index.htm$file = preg_replace('/?WHAT/','tpl_default',$file); // loose the first directory and replace with the default dir....$default_file = file_get_contents("../../tpl/".$file);// read the default template and pull all the tokens....$subject = $default_file;$pattern = "/{.*?}/"; preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);return $matches; // TODO: convert matches to <li> element\[/code\]Having issues with the regex "?WHAT" in line 1 really. Each time the first directory might be something different, so how do I match ONLY the first directory with a wildcard?
 
Top