F
Francois Massion
I am trying to modify the pattern of a sentence with a komma
separating different sections of the sentence. I would like to put at
the end of the sentence what is at the beginning of the sentence.
Current pattern: word1 word2 word3, word4, word5 word6
Expected pattern: word4, word5 word6, word1 word2 word3
Replacement expression:
$sentence =~ s/(.*)(,)(.*)/$3$2$1/;
Actual result: word5 word6,word1 word2 word3, word4
Apparently Perl doesn't start at the beginning of the sentence but
searches backwards. This would be the reason for this result. As some
sentences have only one komma, others more than 2, I would like to
tell Perl to start searching for the first komma in the sentence. How
can I do it?
separating different sections of the sentence. I would like to put at
the end of the sentence what is at the beginning of the sentence.
Current pattern: word1 word2 word3, word4, word5 word6
Expected pattern: word4, word5 word6, word1 word2 word3
Replacement expression:
$sentence =~ s/(.*)(,)(.*)/$3$2$1/;
Actual result: word5 word6,word1 word2 word3, word4
Apparently Perl doesn't start at the beginning of the sentence but
searches backwards. This would be the reason for this result. As some
sentences have only one komma, others more than 2, I would like to
tell Perl to start searching for the first komma in the sentence. How
can I do it?