-1

I have a string as shown below,

$str = 'dev-phase-to-improve == "NOTEQUAL"'

I want to replace:

dev-phase-to-improve == "NOTEQUAL"  

to

!dev-phase-to-improve=""

wondering how can i do that my code is some thing like as shown below,

$rc_link =~ s/'dev-phase-to-improve == "NOTEQUAL"/!dev-phase-to-improve=""/ig;

but it is not working. Any idea?

hwnd
  • 69,796
  • 4
  • 95
  • 132
Ammad
  • 4,031
  • 12
  • 39
  • 62
  • In other words I want final value to be !dev-phase-to-improve == "" from existing dev-phase-to-improve == "NOTEQUAL" – Ammad Jul 21 '15 at 23:42
  • That's not what you said in the question. Which is it? – TLP Jul 21 '15 at 23:47
  • You do not have a `'` in your string, therefore that regex can never match. – TLP Jul 21 '15 at 23:47
  • Any special handling for single or double quote that i need to do at s/'dev-phase-to-improve == "NOTEQUAL"'/!dev-phase-to-improve=""/ig; ? – Ammad Jul 21 '15 at 23:52
  • 1
    Where the pattern is the complete source string, you can simply replace one value with the new one (there's no need for a `s///` command). So, since you're probably not doing it just for the sheer hell of it, what does the source string really look like, and how flexible is the matching? You have `ig` qualifiers after the `s///`, so apparently the string can repeat in the source, and the match may need to be case-insensitive. That's legitimate, but not the impression the question gives. In other words, it is not yet clear what you're really trying to achieve. – Jonathan Leffler Jul 22 '15 at 00:01
  • Hi Jonathan, $rc_link= 'dev-phase-to-improve == "NOTEQUAL"'; $rc_link =~ s/dev-phase-to-improve == "NOTEQUAL"/!dev-phase-to-improve=""/ig; print $rc_link ; – Ammad Jul 22 '15 at 00:05
  • @Ammad `!dev-phase-to-improve=""` is not the same string as `!dev-phase-to-improve == ""`. – TLP Jul 22 '15 at 00:05
  • 1
    I suggest you just write `$rc_link = '!dev-phase-to-improve == ""'` – Borodin Jul 22 '15 at 00:24
  • You do not have a `'` in your string, therefore that regex can never match –  Jul 22 '15 at 00:53

1 Answers1

1

It is working, check out this

my $str = 'dev-phase-to-improve == "NOTEQUAL"';
$str=~ s/dev-phase-to-improve == "NOTEQUAL"/\!dev-phase-to-improve=""/g;
print $str."\n";
sandeep
  • 152
  • 5