From: Ammar Ali Date: 2010-11-03T06:54:00+09:00 Subject: Re: Regular Expression On Tue, Nov 2, 2010 at 11:34 PM, Richard Conroy wrote: > On Tue, Nov 2, 2010 at 9:05 PM, Dv Dasari wrote: > >> I am trying to write a reqular expression to match a word with my input >> string. >> >> Input string can be ( inpstr = ABCDD ) >> >> Any suggestion on how I can fix this? Take a look at looakahead and lookbehind assertions. They used to conditionally match when followed or preceded by a given pattern. > OTOH this regex might scratch your itch: > /^A?B?C?D{0,2}$/ Note that the last quantifier here (the {0,2}) only applies to the last character, the D, not the whole expression. >> "ABBC" =~ /^A?B?C?D{0,2}$/ => nil HTH, Ammar