Joe Christl <> wrote:
> I got my my search part down:
>
> (^[\w\s]{9})B([\w\s]{12})
>
> ... but my replace is a little harder. Basically, I want to find every
> line that has a B in the 10th spot, and replace anything after that
> with X's for the next 12 spots. I could do this:
>
> $1BXXXXXXXXXXXX
>
> as my replace, but actually I'd like to NOT replace spaces and zero's,
> only Alphas and 1-9 digits.
>
> Is there anyone out there that understands regex better than I that can
> help me out?
Regexes are handy so often that we tend to forget that they are
not always the Right Tool for the job.
I'd do it without using any regexes at all:
if ( substr($_, 9, 1) eq 'B') {
substr($_, 10, 12) =~ tr/a-zA-Z1-9/X/; # or: tr/ 0/X/c;
}
--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas