Ovid has asked for the wisdom of the Perl Monks concerning the following question:
Let's, however, assume for the sake of argument that the problem in Regular Expression Help was the following: need to match the beginning of the string, followed by five all caps and a colon and then we need to substitute out the colon. The following is the closest I could do it:
The problem is that I am not matching the five caps to the beginning of the string. Is this impossible with a lookbehind?#!/usr/bin/perl -w use strict; my $test = "ASDFE:asdfe"; $test =~ s! # Substitute (?<= # Zero-width positive lookbehind [A-Z]{5} # Five caps ) # end lookbehind : # Substituting a colon (but not the preceeding + characters) !:</B>\n<BR><BR>!x; print $test;
Cheers,
Ovid
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Yet Another Regex Question
by tye (Sage) on Aug 11, 2000 at 21:29 UTC | |
by Ovid (Cardinal) on Aug 11, 2000 at 21:50 UTC | |
by tye (Sage) on Aug 11, 2000 at 21:55 UTC |