Another version that may do what you want.
#!/usr/bin/perl -w use strict; my @test = qw (20o3oo something 02oo-s 2o0o0o-s 2OoOO); foreach my $x (@test) { print "$x becomes "; $x =~ s|(\d[\doO]+)|my $a = $1; $a=~tr/oO/00/; $a|e; print "$x\n"; } __END__ 20o3oo becomes 200300 something becomes something 02oo-s becomes 0200-s 2o0o0o-s becomes 200000-s 2OoOO becomes 20000
Update: I had neglected the captial O.

A few notes that might help OP on how I arrived at this...
Doing a direct substitution of one char for another is a natural job for tr. However, we don't want to just run amok changing all o or O letters to zeroes (something shouldn't become s0mething). The substitute operator allows a regex to specify the character sequence to apply "tr" upon. You might need to modify this with say "page" as an additional qualifier for the match, but maybe not - you could just run this s/// on every line and that would probably be fine. It is completely allowed to have Perl code calculate the thing that is going to be substituted! Very cool. And that is what the |e; option is all about.


In reply to Re: s/// for \dOO for typos by Marshall
in thread s/// for \dOO for typos [SOLVED] by salmonix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.