On Jul 17, Faymon, Kurt said: >We are currently moving from Omnimark to PERL so I guess it's time to learn >some PERL. Giving the following scenario, I am wondering if PERL can cope >with the following scenario and, if so, what would the code look like:
Oh wow. I'm truly astonished. Omnimark, which touted itself as the replacement for Perl. Wow. Gasp. (Perl, not PERL, please.) Someone who actually used Omnimark. I need a minute to recover. (Omnimark, which is not open-source, debuted itself at OSCON, and said it was "cheaper than Perl". This is a product I have laughed at for quite a while.) ><p>And it says in Documents 1,2,3 and 4 where to go</p> ><p>And it says in Documents <A HREF="Doc1">1</A>,<A HREF="Doc2">2</A>,<A >HREF="Doc3>3</A> and <A HREF="Doc4>4</A> where to go</p> >Basically, I need it to find a pattern anchored by word "Documents" followed >by an undetermined number of #'s, some separated by commas and/or the word >'and' >Is this possible in PERL? Are there any better languages for predominantly >text transformation? I find Perl very VERY good for text transformation. Others might use sed or awk, but Perl has more power. (More power, ar ar ar!) This is how I would approach the problem. It works on the following cases: "Check Document 1" "Check Documents 1 and 2" "Check Documents 1, 2, and 3" "Check Documents 1,2 and 3" "Check Documents 1 , 2, 3, 4, and 5" Here's the code: $string =~ s{(Documents?) (\d+(?:\s*,\s*\d+)*(?:\s*,?\s*and\s+\d+)?)} { $1 . " " . make_links($2) }ge; # find a number, make it a link sub make_links { my $str = shift; $str =~ s{(\d+)}{<a href="Doc$1">$1</a>}g; return $str; } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]