For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2007 > abbreviations









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author abbreviations
Petra Vide Ogrin

2007-08-03, 7:59 am

Hi all,

I have a text with a lot of abbreviations in it and would like to
annotate them. I did it for the shorter ones with

$text =~ m/\b\w{0,3}[^IVX]\./g

and it works fine. But I would like to get the longer ones as well. The
trouble with the long strings ending with a full-stop is that they are
usually proper words at the end of the sentence and not abbreviations.
So I was thinking of another match that would cover longer strings
ending with a full-stop but limiting it with the lowercase beginning of
the next word. I've tried the following

$text =~ m/\b\w{4,8}[^IVX]\.\s\l/g

but it doesn't work - it just gets the words at the end of each
sentence. So this \l at the end of the match is wrong. What should I do
to make it work?

This probably requires some very basic knowledge but since I am an
absolute beginner in perl I am asking for your help,

best,
Petra







Mr. Shawn H. Corey

2007-08-03, 7:02 pm

Petra Vide Ogrin wrote:
> $text =~ m/\b\w{4,8}[^IVX]\.\s\l/g
>
> but it doesn't work - it just gets the words at the end of each
> sentence. So this \l at the end of the match is wrong. What should I do
> to make it work?


Try:

$text =~ m/\b\w{4,8}[^IVX]\.\s[a-z]/g

--
Just my 0.00000002 million dollars worth,
Shawn

"For the things we have to learn before we can do them, we learn by doing them."
Aristotle
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com