Re: best method to perform operations on word lists



Bart Van der Donck schreef:

s/(\.|,|e|en|e,|en,|e\.|en\.)$// for @terms;


Weaker alternative:

(1) s/ (?:e|en)? [.,]? $//x for @terms ;


or even

(2) s/ (?:en?)? [.,]? $//x for @terms ;

It's weaker, because the regex matches the empty string as well.


Proper alternative:

(3) s/(?: en? [.,]? | [.,] )$//x for @terms ;


because it matches at least /e$/ or /[.,]$/.


(untested)

--
Affijn, Ruud

"Gewoon is een tijger."


.



Relevant Pages

  • Re: string matching doesnt work
    ... @c = qw(abc de fghi); ... "Gewoon is een tijger." ... I used Mirco Wahab's solution and it worked for some of the cases but ...
    (comp.lang.perl.misc)
  • Re: Adding hashes
    ... Your 'apples pears' communicated the opposite. ... "Gewoon is een tijger." ...
    (comp.lang.perl.misc)
  • Re: Perl - Joining of Binary values
    ... "Gewoon is een tijger." ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ...
    (perl.beginners)
  • Re: Regular Expression Question Why Doesnt this Match?
    ... Product by abc company ... Your Regex matches almost everything, ... including the empty string. ... prints (lengths of matches): ...
    (comp.lang.perl.misc)
  • Re: XS Progamming with Perl 6
    ... Larry Wall - Present Continuous, Future Perfect ... "Gewoon is een tijger." ...
    (comp.lang.perl.misc)