Hi,
I need help with the split fuction
It seems that perl spilts TWICE when you use an OR (|) and both parts are accepted...
My example:
$rule = "This is a sentence!";
@words = split(/(^[\w]+$)|([\W]+$)/,$rule);
foreach $word (@words)
{
print "$word\|";
}
Perl would give:
This|| |is|| |a|| |sentence||!|
the | shows where Perl split the sentence... It seems he splits TWICE when you OR expression has 2 correct parts... I hope you understand what I'm saying
Is there an Exclusive OR or something?
Basicly, I want to split a sentence in words,spaces and (points,questionmarks,...)
Please help !!
THANX IN ADVANCE !!
math
I need help with the split fuction
It seems that perl spilts TWICE when you use an OR (|) and both parts are accepted...
My example:
$rule = "This is a sentence!";
@words = split(/(^[\w]+$)|([\W]+$)/,$rule);
foreach $word (@words)
{
print "$word\|";
}
Perl would give:
This|| |is|| |a|| |sentence||!|
the | shows where Perl split the sentence... It seems he splits TWICE when you OR expression has 2 correct parts... I hope you understand what I'm saying
Basicly, I want to split a sentence in words,spaces and (points,questionmarks,...)
Please help !!
THANX IN ADVANCE !!
math