
Using a period as a delimiter in the split() function
[Posted and a courtesy copy sent.]
Quote:
> I am currently having a problem with using a period as a delimiter in the
> split function. I am attempting to separate segments of a domain name into
> elements of an array, using the period(s) in the domain name as the
> delimiter. The offending line of code is as follows:
> At the moment a null value is passed to the array. If any of you have any
> suggestions for a way to get around this I would be very grateful.
Yes. Instead of writing the argument for split() as a string, write it
as what it really is, a regex. Then you will see that '.' is a regex
metacharacter, which needs to be escaped to have its literal meaning.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/