in reply to regex CA to California

use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/\bCA\b/)->explain; __END__ The regular expression: (?-imsx:\bCA\b) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- CA 'CA' ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
$ perl -pe " s/\bCA\b/California/ " Hi ca Ca CA dooodie Hi ca Ca California dooodie