Removing the url from text using java

前端 未结 7 1796
梦毁少年i
梦毁少年i 2020-12-15 07:59

How to remove the URLs present in text example

String str=\"Fear psychosis after #AssamRiots - http://www.google.com/LdEbWTgD http://www.yahoo.com/mksVZKBz\"         


        
相关标签:
7条回答
  • 2020-12-15 08:47

    As @Ev0oD mentioned, the code works perfect except in the following tweet I'm working on: RT @_Val83_: The cast of #ThorRagnarok playing "Ragnarok Paper Scissors" #TomHiddleston #MarkRuffalo (https://t.co /k9nYBu3QHu)

    where the token is going to be removed: commentstr = commentstr.replaceAll(m.group(i),"").trim();

    I have faced the following error:

    java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 22

    where the m.group(i) is https://t.co /k9nYBu3QHu)``

    0 讨论(0)
提交回复
热议问题