Abbreviating ordinals only in the middle of an address

2013-01-28 Thread Angela Barone
Hello, I'm trying to abbreviate ordinals(?) that occur only in the middle of an address and I'm having a problem. The line below works: $test_data =~ s/(\S) North (\S)/$1 N. $2/i; however, if the address is something like 901 North St., it abbreviates that as well. I'm wanting it to

Re: Abbreviating ordinals only in the middle of an address

2013-01-28 Thread Jim Gibson
On Jan 28, 2013, at 11:57 AM, Angela Barone wrote: > Hello, > > I'm trying to abbreviate ordinals(?) that occur only in the middle of > an address and I'm having a problem. The line below works: > > $test_data =~ s/(\S) North (\S)/$1 N. $2/i; > > however, if the address is something li

Re: Abbreviating ordinals only in the middle of an address

2013-01-28 Thread Paul Anderson
I'm thinking {2,}\w to match two or more words after north. Sent from my iPhone On 2013-01-28, at 2:57 PM, Angela Barone wrote: > Hello, > >I'm trying to abbreviate ordinals(?) that occur only in the middle of an > address and I'm having a problem. The line below works: > > $test_data

RE: Abbreviating ordinals only in the middle of an address

2013-01-28 Thread Wagner, David --- Sr Programmer Analyst --- CFS
>-Original Message- >From: Paul Anderson [mailto:wackyvor...@me.com] >Sent: Monday, January 28, 2013 13:32 >To: Angela Barone >Cc: beginners@perl.org >Subject: Re: Abbreviating ordinals only in the middle of an address > >I'm thinking {2,}\w to match two or mo

Re: Abbreviating ordinals only in the middle of an address

2013-01-28 Thread Brandon McCaig
Paul Anderson: On Mon, Jan 28, 2013 at 03:32:01PM -0500, Paul Anderson wrote: > I'm thinking {2,}\w to match two or more words after north. /{2,}\w/ is not a valid regex. This is what perl will tell you (if your regex is exactly this and there's nothing in front of it to unintentionally precede

Re: Abbreviating ordinals only in the middle of an address

2013-01-29 Thread Nathan Hilterbrand
On 01/28/2013 02:57 PM, Angela Barone wrote: Hello, I'm trying to abbreviate ordinals(?) that occur only in the middle of an address and I'm having a problem. The line below works: $test_data =~ s/(\S) North (\S)/$1 N. $2/i; however, if the address is something like 901 North St., it

Re: Abbreviating ordinals only in the middle of an address

2013-01-29 Thread Tushar N K Jain
I am not an expert in Perl, but wouldn't $test_data =~ s/north/N./gi; be sufficient? Regards, Tushar Jain On Mon, Jan 28, 2013 at 2:42 PM, Nathan Hilterbrand wrote: > On 01/28/2013 02:57 PM, Angela Barone wrote: > >> Hello, >> >> I'm trying to abbreviate ordinals(?) that occur only in

Re: Abbreviating ordinals only in the middle of an address

2013-01-29 Thread Angela Barone
On Jan 28, 2013, at 1:07 PM, Jim Gibson wrote: > This is known as a "negative lookahead assertion" and uses the (?!...) > construct: Thanks, everyone. I went with the negative lookahead that Jim mentioned. It works like a charm! Thanks again, Angela

Re: Abbreviating ordinals only in the middle of an address

2013-01-29 Thread John SJ Anderson
On Jan 29, 2013, at 8:19 AM, Tushar N K Jain wrote: > I am not an expert in Perl, but wouldn't > > $test_data =~ s/north/N./gi; > > be sufficient? And what's the output of that when somebody lives on 'South Northgate Lane'? j. -- John SJ Anderson // geneh...@genehack.org -- To unsub