If I understand your problem correctly, you want to collapse the '.' or ' ' guys that are between '|'. So how about using split and a map to break apart and rebuild your string?
while(<DATA>) { print; chomp; tr/\cM//d; my @x = split(/\|/,$_); my @y = map{($_ =~ /[\. ]/)?"":$_}@x; print join("|",@y) . "\n"; } __DATA__ 6|11-XXX-03|999999999|.| |0000|.|.|.|.|.|.| | |.| | | | |.|.| |.|0|N
This produces
when it runs.6|11-XXX-03|999999999|||0000||||||||||||||||||0|N
Don't forget that split takes a regexp, not a quoted string. The "|" works out to (null)or(null), which means every position matches. Thus you get '|' between each character.
Final note: Don't always try to do everything with a regular expression. split and join are your friends.
--t. alexIn reply to Re: regex help!
by talexb
in thread regex help!
by Plankton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |