Nandini Posted August 28, 2008 Share Posted August 28, 2008 i dont know about regular expresiion. So i need asistance. I have string like "username:password@host:port/username" OR "username:password:username@host:port/username" I want to split upto "username:password@host" if string is "username:password@host:port/username" OR I want to split upto "username:password:username@host" if string is "username:password:username@host:port/username" Here username,password,host and port values may be changed after every transaction. Can anyone help me. Quote Link to comment Share on other sites More sharing options...
effigy Posted August 28, 2008 Share Posted August 28, 2008 <pre> <?php $tests = array( 'username:password@host', 'username:password@host:port/username', 'username:password:username@host:port/username', ); foreach ($tests as $test) { echo "<b>$test</b><hr>"; $pieces = preg_split('%?=[^@]+\z)%', $test); print_r($pieces); } ?> </pre> 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.