I want to find a text within the string and replace it but it’s not working my code. I have to mention that i get normally the Title of the webview, but when i output the text2 i get the whole title (does not replace the text). Also all strings except from text2 , located within a void.
String text1 = web1.getTitle();
String text2 = text1.toString().replace("-Click 2U - Files", "");
Thank you in advance….
Your code works for me:
This will remove all instances of the string. You can also use
replaceAll(...)which uses regular expressions:Notice that the
"C.*?k"pattern will match aCand then any number of characters and thenk. The?means don’t do an eager match and stop at the firstk. Read your regex manuals for more details there.