johnsmith153 Posted January 19, 2011 Share Posted January 19, 2011 I have never understood regular expressions, or spent enough time trying to. I could do with help being able to remove everything before a set value. So "jhfwhfeijhfgeih VALUE wufhehiehriehr" would return "VALUE wufhehiehriehr" Should be easy. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted January 19, 2011 Share Posted January 19, 2011 Try learning them. It is fun and very useful. $new = preg_replace('/.*(VALUE.*)/', '$1', $old); Quote Link to comment Share on other sites More sharing options...
Goose Posted January 19, 2011 Share Posted January 19, 2011 This solution isn't using regular expressions, but I think it might be quicker. If you are sure that you will have that pattern you showed above you can do this: $pos = strpos($yourString, ' '); if($pos !== false){ $yourNewString = substr($yourString, $pos + 1); } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted January 19, 2011 Share Posted January 19, 2011 Yes, or even shorter: $new = strstr($old, 'VALUE'); Quote Link to comment Share on other sites More sharing options...
Goose Posted January 19, 2011 Share Posted January 19, 2011 Good call. 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.