kanch33 Posted July 14, 2009 Share Posted July 14, 2009 For instance, I have the following string: table:column I need to get "table" as the result of the php regular expression. So, I need everything before the ":" symbol After that regular expression is performed, I would also like to get everything after the ":" symbol, or "column" as well. Quote Link to comment https://forums.phpfreaks.com/topic/165947-what-is-the-php-regular-expression-to-get-everything-before-a-certain-character/ Share on other sites More sharing options...
mattal999 Posted July 14, 2009 Share Posted July 14, 2009 Could just explode by ":". Example: <?php $string = "table:column"; $exploded = explode(":", $string); $table = $exploded[0]; $column = $exploded[1]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/165947-what-is-the-php-regular-expression-to-get-everything-before-a-certain-character/#findComment-875240 Share on other sites More sharing options...
premiso Posted July 14, 2009 Share Posted July 14, 2009 explode $string = "table:column"; list($table, $column) = explode(":", $string); echo $table . " " . $column; Will hopefully get you started. EDIT: Still posting as I used the list and is a different method to accomplish what the user wants Quote Link to comment https://forums.phpfreaks.com/topic/165947-what-is-the-php-regular-expression-to-get-everything-before-a-certain-character/#findComment-875241 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.