On 23 October 2001 12:21 Jerry Preston [mailto:[EMAIL PROTECTED]] wrote:
> I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts.  I
> can do it with split:
> 
>           ( $a1,$a2,$a3,$a4 ) = split( /\./, $program );
> 
> How do I do it with           s/\b(\.)\b(\.)\b(\.)\b(\.)/?
> 


You can't, since:

1. that regex of word boundary (i.e. non-word-character (\W) followed by
word-character (\w) or visa versa) followed by a period 4 times can't occur
('....' doesn't contain any word boundaries).

2. a substituion (s///) needs a regex (between the first and second
delimeters) and then some to replace the match with (between the second and
third[1])

What do you actually want to do here?

If you want to replace part of the input string a subsitution is likely to
be the right thing to do, OTOH something like (untested)

my @parts = split(/\./, $program);
$parts2 = 'fred';
$pragram = join('.',@parts);

might be easier to understand; the same in a substitution would be something
like (also untested)

$program =~ s!(?<=\.)[^.]+!fred!;

(The match part of which is: match non-periods that follow a period.)


Richard Cox 
Senior Software Developer 
Dell Technology Online 
All opinions and statements mine and do not in any way (unless expressly
stated) imply anything at all on behalf of my employer




[1] Or 3rd and 4th if using matched separators as in s{}<>.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to