Question about the String.replaceAll() and String.replaceFirst() method.

Posted by Java Doe on Stack Overflow See other posts from Stack Overflow or by Java Doe
Published on 2010-05-13T13:34:28Z Indexed on 2010/05/13 13:44 UTC
Read the original article Hit count: 141

Filed under:
|
|

I need to do a simple string replace operation on a segment of string. I ran into the following issue and hope to get some advice.

  1. In the original string I got, I can replace the string such as to something else.
  2. BUT, in the same original string, if I want to replace a much long string such as the following, it won’t work. Nothing gets replaced after the call.

    <div class="more"><a href="http://SERVER_name/profiles/atom/mv/theboard/entries/related.do?email=xyz.com&ps=20&since=1273518953218&sinceEntryId=abc-def-123-456">More...</a></div>

I tried these two methods:

originalString.replaceFirst(moreTag, newContent);
originalString.replaceAll(moreTag, newContent);

Thanks in advance.

© Stack Overflow or respective owner

Related posts about java

Related posts about string