Help for this page

Select Code to Download


  1. or download this
    $ perl -lE '
    my ($haystack,$needle)=@ARGV;
    ...
    found at 0
    found at 6
    found at 13
    
  2. or download this
    $ perl -lE '
    my ($haystack,$needle,$new)=@ARGV;
    ...
    say "new string: $haystack" 
    ' abcsdfabcasegabc abc foo
    new string: foosdffooasegfoo
    
  3. or download this
    s/\Q$str\E/$new/g; # since \E is at the end, it's not really required.