[Java lista] String kérdés

CoL col at gear.hu
2009. Aug. 3., H, 19:06:09 CEST


Szia,

Marai Laszlo wrote:
> On Mon, 03 Aug 2009 18:13:31 +0200
> CoL <col at gear.hu> wrote:
>
>   Hali!
>
>   
>>> amivel próbálkoztam és nem ment:
>>> tobbSorosString1.replace(tobbSorosString2,tobbSorosString3);
>>>       
>> replaceAll mellesleg regexp-et szeretne első paraméternek.
>>     
>
> Es a regex alapvetoen sor orientaltan mukodik, vagyis szerintem nem tudsz
> vele sorveget matchelni. Be lehet allitani, hogy tobbsoros legyen a
> mukodes, de a String.replace-nek ezt nem lehet megadni. Vagy Pattern-t (es
> Matcher-t kell hasznalni), vagy trukkozni kell. Az egyik megoldas, hogy
> indexof-fal megkeresed a celstringet, aztan kezzel kivagod (substring).
>   

igazad van. de a string.replacaAll sem mas mint  matcher stb meghivasa:) 
Ergo transormalhato a kod ilyesmire:
Pattern.compile( 
"(csereszoveg",Pattern.MULTILINE).matcher(szoveg).replaceAll("masikszoveg");

C.



További információk a(z) Javalist levelezőlistáról