How to replace first occurrence of string in Java -


i want replace first occurrence of string in following.

  string test = "see comments, test, us" 

**if test contains input follows should not replace

  1. see comments, (with space @ end)
  2. see comments,
  3. see comments**

i want output follows,

 output: test, 

thanks in advance,

you can use replacefirst(string regex, string replacement) method of string.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -