On Thursday 29 April 2004 10:31, Owen wrote:
> I would like to replace all instances of
>
> @non_space_characters[non_space_characters] with
> $non_space_characters[non_space_characters]
>
> The program below gets the first one only. How do I get the others?
>
> TIA
>
> Owen
> ---
Owen wrote:
>
> I would like to replace all instances of
>
> @non_space_characters[non_space_characters] with
> $non_space_characters[non_space_characters]
>
> The program below gets the first one only. How do I get the others?
>
> ---
> #!/usr/
Hi Owen,
I think I would do things a little differently.
Owen wrote:
I would like to replace all instances of
@non_space_characters[non_space_characters] with
$non_space_characters[non_space_characters]
[...]
$line=~s/(@)(\S+\[\S+\])/\$$2/g;
__DATA__
@[EMAIL PROTECTED]@banana[4];
So this is my
The problem is that your regex is matching the whole line:
@ [EMAIL PROTECTED]@banana[4];
^ ^
$1 $2
Instead, use non greedy matches:
$line =~ s/(@)(\S+?\[\S+?\])/\$$2/g;
and you'll get what you want:
@ array[1] = @ array[2] +@ banana[4];
^ ^