David wrote:
> I have a perl script where I match on phrase to add
something after
> that phrase:
> $line=~s/PILOT_INC=4,/PILOT_INC=4, NGHBR_SRCH_MODE =
0,/g;
>
> However, the "4" can be variable, say,
anything between 2 and 8.
>
> I'd like to do something like this:
> $line=~s/PILOT_INC=d,/PILOT_INC=d, NGHBR_SRCH_MODE =
0,/g;
> Of course this won't work.
>
> Do I need to first save the number into a variable and
then put that
> variable into the regex replace phrase or can it be
done within the
> global search and replace regex line above?
>
> regards, David
Or you can try the following:
$line=~s/PILOT_INC=([2-8]),/PILOT_INC=$1, NGHBR_SRCH_MODE =
0,/g;
Regards,
Manish
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps-beta.google.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|