Re: replacing this backlash (\) with no backlash

From: Anno Siegel (anno4000_at_lublin.zrz.tu-berlin.de)
Date: 02/24/04


Date: 24 Feb 2004 15:50:24 GMT

Devop <as@hotmail.com> wrote in comp.lang.perl.misc:
> -=-=-=-=-=-
>
> hi.
>
> I have been replacing string with backslas (\) with an other without
> backlash.
>
> This is part of the code
> The reason i use \ in front of $ is that , $ is included in my search.
>
> But when i replaced with the second variable, i get \${string2} - i
> love you & (see the backlash is with me again ? how can i ignore this
> backlash? . I want to get just {string2} - i love you &
>
> my $first = '\${string1} &';
               ^
That backslash has no function in single quotes, it is included literally
in your string. Print out "$first" before the substitution to see it.

> my $second = '\${string2} - i love you &';

Since your substitution does nothing about a literal backslash, it stays in.
You don't want to "ignore" the backslash, you don't want to put it in the
original string in the first place.

    my $first ='${string1} &';

Anno



Relevant Pages

  • Re: gfortran diagnostics and so on
    ... Well, in f0003, backslash is part of the standard Fortran character set. ... Because the backslash is part of the standard Fortran character set, the default behavior should be the printable character, **NOT** some kind of magic introductory character that transforms the interpretation of following character. ... The one I like best is to use one of the popular extensions to designate a particular literal string according to the C language. ...
    (comp.lang.fortran)
  • Re: Double backslashes \ in strings
    ... and the single backslash isn't ... The simplest way to specify a string is to enclose it in single quotes. ... echo ''; ...
    (comp.lang.php)
  • Re: Convert to /
    ... |> Why is it so hard to convert backslashes to forward slashes in java? ... | character immediately after the colon would be the tab ... | get a backslash character into a string literal in Java ...
    (comp.lang.java.help)
  • Re: Raw String Question
    ... backslashes are left in the string. ... backslash as the last character of a string without doubling it". ... regular expressions without doubling all the backslashes. ...
    (comp.lang.python)
  • Re: String variable read from Mysql DB + echo = Newline problem
    ... The string already has single backslash in the database. ... And BTW - you cannot exactly control formatting on the user's browser. ...
    (comp.lang.php)