Re: String.replaceAll won't work :s
From: Passero (bla_at_bla.bla)
Date: 07/01/04
- Next message: Stefan Waldmann: "Re: String.replaceAll won't work :s"
- Previous message: Stefan Waldmann: "Re: another prob"
- In reply to: Stefan Waldmann: "Re: String.replaceAll won't work :s"
- Next in thread: Stefan Waldmann: "Re: String.replaceAll won't work :s"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 01 Jul 2004 11:10:52 GMT
"Stefan Waldmann" <stefan.k.waldmann@vr-web.de> schreef in bericht
news:2ki9d8F2ltuiU3@uni-berlin.de...
> Hello,
>
> the String#replaceAll(...) method expects a regular expression (regex)
> as first parameter. In regular expressions the "\" has also escape
> function (just like in java Strings). Thus, a regex you would write "\\"
> to match a single "\". But because in java you also have to write "\\"
> to get a single "\" inside the String, what you have to use is "\\\\".
>
> So this should do what you want to achieve:
>
> myString = myString.replaceAll("\\\\","\\\\");
>
> Not kidding! The second parameter is no regex, but only the String which
> should replace all matches of the first param. Try it.
>
Yeah thanks it works but as a second parameter i had to give "////////"
instead of "////"
Very strange but i tried it and when i use "////" as second parameter, he
doesn't change anything.
>
>
> Greetings, Stefan
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.600 / Virus Database: 381 - Release Date: 28/02/2004
- Next message: Stefan Waldmann: "Re: String.replaceAll won't work :s"
- Previous message: Stefan Waldmann: "Re: another prob"
- In reply to: Stefan Waldmann: "Re: String.replaceAll won't work :s"
- Next in thread: Stefan Waldmann: "Re: String.replaceAll won't work :s"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|