mkelley Posted February 2, 2007 Share Posted February 2, 2007 I have the code below and it produces <title>M.Kelley</title> <link rel='stylesheet' href='mkelley.com.css' type='text/css' /> <?php $new_domain = $_SERVER['HTTP_HOST']; switch ($new_domain){ case "mkelley.com": echo "<title>M.Kelley</title>"; echo "<link rel='stylesheet' href='$new_domain.css' type='text/css' />"; break; case "www.mkelley.com": echo "<title>M.Kelley</title>"; echo "<link rel='stylesheet' href='$new_domain.css' type='text/css' />"; break; } ?> I'm very very new to regex, how can I remove the . from domain.com or from www.domain.com ? I'd like it to produce <title>M.Kelley</title> <link rel='stylesheet' href='mkelleycom.css' type='text/css' /> Quote Link to comment Share on other sites More sharing options...
c4onastick Posted February 2, 2007 Share Posted February 2, 2007 This is one way: $text = preg_replace('/\.(?!css)/', '', $text); Assuming you're just dealing with the form 'foo.com.css' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.