Page 1 of 1

Difference between explode and split

Posted: Mon Apr 14, 2003 7:34 am
by oQEDo
Im not too sure of how the functions split and explode work. Their explainations are pretty similar in the notes however the differences are:

Split
....splitting it on boundaries formed by the string separator
Explode
.....splitting it on boundaries formed by the regular expression pattern
Can someone please give me a simple explaination of what this actually means :?:

Thanks

Posted: Mon Apr 14, 2003 8:46 am
by Stoker
Split uses Regular Expressions, Explode uses pure strings.. If you don't need regular expression power, use Explode, it's much faster/less resource-using.. (Just as it says in the manual)

Regular Expression

Posted: Tue Apr 15, 2003 3:49 am
by oQEDo
Thanks Stoker however for my next question.....
What is a regular expression?
Could you give me an example of a regular expression and an example of something which is not a regular expression? I'm finding it tricky to get my head round this.

Thanks

Posted: Tue Apr 15, 2003 5:37 am
by twigletmac
A regular expression is used to match a pattern, so for example you might want to search for all instances of e-mail addresses - they're each going to be different (me@mydomain.com, you@yourdomain.net) but they follow a similar pattern. For this you would use a regular expression to match that pattern.

If, however, you wanted to find all instances of me@mydomain.com, then you wouldn't use a regular expression because it's the same string that you're searching for each time.

Found this in Google:
http://www.regularexpression.info/

Mac

Posted: Tue Apr 15, 2003 6:53 am
by oQEDo
Thanks twigletmac,

Thats exactly what I was looking for.