Ala Qumsieh wrote:
> Gunnar Hjalmarsson wrote:
>> Subra wrote:
>>> $line=~s/(^#.*)__linux__(.*)/$1__linux$2/g;
>>> $line=~s/(^#.*)LINUX(.*)/$1__linux$2/g;
>>> $line=~s/(^#.*)[\s]+linux(.*)/$1 __linux $2/g;
>> That could possibly be written:
>>
>> $line =~ s/(^#.*?)(?:__)?linux(?:__)?/$1__linux/gi;
>
> you meant this:
>
> $line =~ s/(^#.*?)(?:__)?linux(?:__)?/${1}__linux/gi;
>
> the OP had it wrong too, and I suspect you just copied/pasted.
Well, no, to be honest I didn't think of it, but I had tested the code
before posting.
Now, when I play with various alternatives, it seems as if the braces
are only needed if the string following the dollar-digit variable begins
with a digit.
--
Gunnar Hjalmarsson
Email:
http://www.gunnar.cc/cgi-bin/contact.pl