While the code is obviously not perfect, I do not see why would it not work. It will probably help to see some of the original strings that go into these substitutions. ( Do they have "end-of-lines" embedded in them ? ) Eugene Haimov
-----Original Message----- From: michael higgins [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 25, 2002 1:42 PM To: [EMAIL PROTECTED] Subject: regex help? Hello -- I've been lurking about this list for a while, learned a lot - mostly just that I have a lot to learn. I'm not a programmer... but I'm very interested in it, and have gotten myself to this point by desire. I cut my teeth with the syntax and behavior when I made a few utilities to write linked html pages as a looping narrative from a template... and some other things, like CGI stuff, forms, etc. Anyway, I got excited because managed to use the Xbase.pm to fix a long troubling problem with a FoxPro data set -- performing functions not included with the front-end designed for fundraising. (I expect to be able to read the student home addresses from one file and switch with current address in another file when they graduate. ) The problem hanging me up right now is the fixed field length in the .dbf is too short -- so I decided to shorten most strings with the following regexes.( I also want to eliminate a 'second line' in the .dbf, so we can use it for something else, this is why the field is now too short.) So, I'm abbreviating the longer, common strings and stuffing into one field The bit of code: my $street = "$add"." "."$secln"; $street=~s/,//; $street=~s/(\b)Apartment(\s)|(\b)Apt(\s)/$1Apt\.$2/i; $street=~s/(\b)Boulevard(\s)|(\b)Blvd(\s)/$1Blvd\.$2/i; $street=~s/(\b)Street(\s)|(\b)St(\s)/$1St\.$2/i; $street=~s/(\b)Drive(\s)|(\b)Dr(\s)/$1Dr\.$2/i; $street=~s/(\b)Avenue(\s)|(\b)Ave(\s)/$1Ave\.$2/i; $street=~s/(\b)Circle(\s)|(\b)Cir(\s)/$1Cir\.$2/i; Now, the problem is likely obvious: how do I perform all the necessary substitutions on the same string? What happens is that the string matches only one substitution, say Apt. for Apartment and leaves 'Street' or 'Avenue'. These replace fine when the sole potential match, regardless of the location in the string. Perhaps I'm approaching this entirely the wrong way, but I've read some bundled documentation and my Deitel, but, I still don't have the answer to this problem, or a better idea to get it done. TIA? I'm on win98, activeState install... if this matters... -- Michael Higgins Development Associate Joseph Slifka Center for Jewish Life at Yale [EMAIL PROTECTED] 203-265-5984 _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
