-1

I'm getting a text extracted from qrcode from my application, but as I am using zxing library its putting an extra DEMO at the end. How to remove it from there? I was trying this but it does not work:

String aboutText = (Global.text).toString();
aboutText = aboutText.replace("DEMO", " ");
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Ritu
  • 1,047
  • 4
  • 12
  • 22

2 Answers2

0

String.replace only takes chars as argument. Try String.replaceFirst(String, String) instead.

aboutText = aboutText.replaceFirst("DEMO", " ");

shout work. You can also take a look at replaceAll

Fortega
  • 19,463
  • 14
  • 75
  • 113
  • ok iam able to sort out this one removing DEMO from the text generated..aboutText = aboutText.replaceFirst("DEMO", " ");...but it will replace DEMO from the text where ever it happens..want to remove it from end only.. – Ritu Aug 22 '11 at 08:59
  • You can write your own 'replaceLast' method... For example: http://stackoverflow.com/questions/1660034/replace-last-string/5254817#5254817 – Fortega Aug 22 '11 at 09:02
  • thnx fortega....but i m intrested in replacing the last occurence od the "DEMO" ..but unfortunately dere is no func called..replacelast()..neways thnx for the link..i'll try it.. – Ritu Aug 22 '11 at 09:46
0

Here you are: String. As for a newbie it will be quite helpful to learn more about strings in Java and the operations with them.

Egor
  • 39,695
  • 10
  • 113
  • 130
  • but i am stuck in the second part .... that is from the extracted text from qrcode...how can i distinguish b/w ,which is SMS,Email,URL etc..and perform actions accordingly... – Ritu Aug 22 '11 at 09:38