|
Posted by Rik on 07/24/07 16:40
On Tue, 24 Jul 2007 18:11:53 +0200, Geoff Berrow <blthecat@ckdog.co.uk> =
=
wrote:
> Does anyone know what regular expression I would use to split text int=
o
> an array, assuming the text can be separated by any non alphanumeric
> character?
$array =3D preg_split('/\W+/',$string,-1,PREG_SPLIT_NO_EMPTY);
\W =3D non-word character
"A "word" character is any letter or digit or the underscore character, =
=
that is, any character which can be part of a Perl "word". The definitio=
n =
of letters and digits is controlled by PCRE's character tables, and may =
=
vary if locale-specific matching is taking place. For example, in the "f=
r" =
(French) locale, some character codes greater than 128 are used for =
accented letters, and these are matched by \w."
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|