Re: Capitalizing Acronyms

2011-10-07 Thread Rob Dixon
On 07/10/2011 17:25, Marc wrote: On Oct 7, 2011, at 8:07 AM, Rob Dixon wrote: Capturing parenthese should be avoided unless the are needed This I don't understand. Since we're using $1 we need them, no? $string =~ s/\b(?:[aeiouy]{3,4}|[bcdfghjklmnpqrstvwxz]{3,4})\b/\U$1/gi; Thi

Re: Capitalizing Acronyms

2011-10-07 Thread Marc
On Oct 7, 2011, at 8:07 AM, Rob Dixon wrote: > Just add the /i modifer (as you had originally) and there is no need to list > both the upper and lower case alphabetics. Of course. Err... :\ > Capturing parenthese should be avoided unless the are needed This I don't understand

Re: Capitalizing Acronyms

2011-10-07 Thread Rob Dixon
On 07/10/2011 01:38, Marc wrote: > On Oct 6, 2011, at 4:44 PM, Jim Gibson wrote: > >> You should go back to your original character class of [bcdfghjklmnpqrstvwxz] > > Making this change fixed the "Rex'S" problem, but it didn't capitalize > LKJ because the rest of the code had capitalized

Re: Capitalizing Acronyms

2011-10-07 Thread Igor Dovgiy
You know, it shouldn't be mile long. ) $string =~ s! \b (?=[a-z]{3,4}) ([aeiouy]{3,4}|[^aeiouy]{3,4}) \b !\U$1!igx; -- iD 2011/10/7 Marc > On Oct 6, 2011, at 4:44 PM, Jim Gibson wrote: > > > You should go back to your original character class of > [bcdfghjklmnpqrstvwxz] > > Making this

Re: Capitalizing Acronyms

2011-10-06 Thread Marc
On Oct 6, 2011, at 4:44 PM, Jim Gibson wrote: > You should go back to your original character class of [bcdfghjklmnpqrstvwxz] Making this change fixed the "Rex'S" problem, but it didn't capitalize LKJ because the rest of the code had capitalized the acronym as Lkj. So I changed that li

Re: Capitalizing Acronyms

2011-10-06 Thread Jim Gibson
On 10/6/11 Thu Oct 6, 2011 4:05 PM, "Marc" scribbled: > On Sep 8, 2011, at 10:13 AM, Rob Dixon wrote: > >> my $string = 'The Kcl Group'; >> >> $string =~ s/\b([aeiouy]{3,4}|[^aeiouy]{3,4})\b/\U$1/ig; >> >> print $string, "\n"; > > I'd like to revisit this, if I could. I've modified the abo

Re: Capitalizing Acronyms

2011-10-06 Thread Marc
On Sep 8, 2011, at 10:13 AM, Rob Dixon wrote: > my $string = 'The Kcl Group'; > > $string =~ s/\b([aeiouy]{3,4}|[^aeiouy]{3,4})\b/\U$1/ig; > > print $string, "\n"; I'd like to revisit this, if I could. I've modified the above regex so as not to capitalize ordinal numbers, however I've

Re: Capitalizing Acronyms

2011-09-08 Thread Marc
On Sep 8, 2011, at 10:13 AM, Rob Dixon wrote: > $string =~ s/\b([aeiouy]{3,4}|[^aeiouy]{3,4})\b/\U$1/ig; Thanks to everyone who responded. I was trying to be concise but I went about it the wrong way and ended up creating more work for myself. I like the above code as it allows me to

Re: Capitalizing Acronyms

2011-09-08 Thread Shlomi Fish
On Thu, 8 Sep 2011 09:55:33 -0700 Marc wrote: > Hi Shlomi, > > > The problem here that /g confuses Perl and puts it in the \G anchor mode. > > Removing both /g fixes the problem. Some other notes: > > > > 1. You don't really need to say [...]+ inside the regex. [] here would > > be > > eno

Re: Capitalizing Acronyms

2011-09-08 Thread Rob Dixon
On 08/09/2011 16:58, Marc wrote: use strict; use warnings; my $string = 'The Kcl Group'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word>= 3 and length $word<= 4) and ($word !~ m/[aeiouy]+/gi or $word !~ m/[bcdfghjklmnpqrstvwxz]+/gi)) {

Re: Capitalizing Acronyms

2011-09-08 Thread Uri Guttman
> "M" == Marc writes: M> Jim and David, >> m/^[aeiouy]+$/i M> I tried your suggestions but it still gives the same result: M>my $string = 'Off The Menu'; M>my @words = split(/ /, $string); M>my @new_words; M>foreach my $word (@words) { M>

Re: Capitalizing Acronyms

2011-09-08 Thread Uri Guttman
> ""D" == "Wagner, David <--- Sr Programmer Analyst --- CFS" > > writes: "D> ! ($word =~ m/^[aeiouy]+&/gi or $word =~ m/^[bcdfghjklmnpqrstvwxz]+&/gi) "D> This forces a start and end of on $word and I like the positive of if ONLY vowels plus Y or ONLY consonants. SO it is one way o

Re: Capitalizing Acronyms

2011-09-08 Thread Brandon McCaig
On Thu, Sep 8, 2011 at 11:58 AM, Marc wrote: > I'm trying to capitalize 3 and 4 letter words that contain > only vowels or consonants, but not both.  The code I've come > up with is not working correctly.  Given the string > 'The Kcl Group', it should return 'The KCL Group' but it is > also capita

Re: Capitalizing Acronyms

2011-09-08 Thread Jim Gibson
On 9/8/11 Thu Sep 8, 2011 9:38 AM, "Marc" scribbled: > Jim and David, > >> m/^[aeiouy]+$/i > > I tried your suggestions but it still gives the same result: > > my $string = 'Off The Menu'; > > my @words = split(/ /, $string); > my @new_words; > foreach my $word (@words) { > if ((length $wo

Re: Capitalizing Acronyms

2011-09-08 Thread Marc
Hi Shlomi, > The problem here that /g confuses Perl and puts it in the \G anchor mode. > Removing both /g fixes the problem. Some other notes: > > 1. You don't really need to say [...]+ inside the regex. [] here would be > enough. Unfortunately, removing the /g and the + doesn't help

Re: Capitalizing Acronyms

2011-09-08 Thread timothy adigun
Hi Marc, Please check >>> comment in your code below: use strict; use warnings; my $string = 'The Kcl Group'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { >>> if ((length $word >= 3 and length $word <= 4) and ($word !~ m/[aeiouy]+/gi or $word !~ m/[bcdf

Re: Capitalizing Acronyms

2011-09-08 Thread Marc
Jim and David, > m/^[aeiouy]+$/i I tried your suggestions but it still gives the same result: my $string = 'Off The Menu'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word >= 3

Re: Capitalizing Acronyms

2011-09-08 Thread Shlomi Fish
Hi Marc, On Thu, 8 Sep 2011 08:58:09 -0700 Marc wrote: > I'm trying to capitalize 3 and 4 letter words that contain only vowels > or consonants, but not both. The code I've come up with is not working > correctly. Given the string 'The Kcl Group', it should return 'The KCL > Group' bu

Re: Capitalizing Acronyms

2011-09-08 Thread Jim Gibson
On 9/8/11 Thu Sep 8, 2011 8:58 AM, "Marc" scribbled: > I'm trying to capitalize 3 and 4 letter words that contain only vowels or > consonants, but not both. The code I've come up with is not working > correctly. Given the string 'The Kcl Group', it should return 'The KCL Group' > but it is al

RE: Capitalizing Acronyms

2011-09-08 Thread Wagner, David --- Sr Programmer Analyst --- CFS
>-Original Message- >From: Marc [mailto:sono...@fannullone.us] >Sent: Thursday, September 08, 2011 9:58 >To: Perl Beginners >Subject: Capitalizing Acronyms > > > I'm trying to capitalize 3 and 4 letter words that contain only >vowels or consonants, but not both. The code I've come up