mavericknik has asked for the wisdom of the Perl Monks concerning the following question:
I then have a cell like so:\u0/r0/rcnt[3]
I need to switch the values in after the brackets in .IN1 and .IN2 so the output should be:NOR2X0 U2905 ( .IN1(\u0/r0/rcnt[3] ), .IN2(\u0/r0/n43 ), .QN(n1699) ) +;
The part of the code doing that right now is:NOR2X0 U2905 ( .IN1(\u0/r0/n43 ), .IN2(\u0/r0/rcnt[3] ), .QN(n1699) +);
But this throws an error:foreach my $val (@nets_q) { $data =~ s/( [NOR|OR].*.IN1\()($val)(\).*IN2\()([^\)]*)(.*)/$1$4$3 +$2$5/g; }
So it is considering the "\u" part of "\u0/ro/rcnt3" as an escape character. How would I go about doing this? Is this the right way? Thanks in advance!Unrecognized escape \u passed through in regex;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing a variable to a regex
by choroba (Cardinal) on Sep 17, 2015 at 10:37 UTC | |
by mavericknik (Sexton) on Sep 17, 2015 at 11:05 UTC | |
|
Re: Passing a variable to a regex
by Athanasius (Archbishop) on Sep 17, 2015 at 11:17 UTC | |
by mavericknik (Sexton) on Sep 17, 2015 at 11:37 UTC |