zerugaze Posted February 26, 2009 Share Posted February 26, 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. Link to comment https://forums.phpfreaks.com/topic/146991-what-is-the-php-regular-expression-to-get-everything-before-a-certain-character/ Share on other sites More sharing options...
Zane Posted February 26, 2009 Share Posted February 26, 2009 you could just explode by colon list($table, $column) = explode(":","table:column"); echo $table; echo $column; Link to comment https://forums.phpfreaks.com/topic/146991-what-is-the-php-regular-expression-to-get-everything-before-a-certain-character/#findComment-771737 Share on other sites More sharing options...
sasa Posted February 26, 2009 Share Posted February 26, 2009 if(!(strpos($string, $symbol)===false)){ $before = substr($string, 0, strpos($string, $symbol)); $after = substr($string, strpos($string, $symbol)+1); } Link to comment https://forums.phpfreaks.com/topic/146991-what-is-the-php-regular-expression-to-get-everything-before-a-certain-character/#findComment-771738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.