> -----Original Message----- > From: Miretsky, Anya [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 15, 2001 11:37 AM > To: '[EMAIL PROTECTED]' > Subject: Regulare Expressions/ Substitution Question > > > I am trying to replace all occurences of the word St with St. without > generating St.. in the incorrect substitutions of St. > > The code I have been playing with is something like: > > $item = "35 Main St." (it could also be "35 Main St" in which > case I want > the substitution to happen) > > $varS = "st"; > $item =~ s/\b$varS(^.|\W)\b/St./gi; > > This doesn't work because Perl is expecting a character after > the $varS > string, but I don't know how to specify to substitute for the > contents of > $varS except when it ends with a period.
Why not just s/\b$varS\b/St./gi; You only want to add the period if St begins and ends on a word boundary, no? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]