• Post Reply Bookmark Topic Watch Topic
  • New Topic

The String.replaceAll() method?  RSS feed

 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using the regular expression features in the JDK String class but have some problems. I'd appreciate any help. If I use the replaceAll() method of against a long string (e.g. to replace all HTML tags in a long web page), it will crash or stall without throwing an exception. I tested on both Windows and Mac OS X platfoprms.
Does anyone have similar experiences? Thanks a lot
cheers
Michael
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post an example?
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. For example, I would download a web page into a string variable "cache" and do the following to get rid of the HTML tags:

The above statement never throws any exception but will crash the thread or stall for some pages. It does work on some pages though.
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you need to have two backslashes in that regexp, rather than just one?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!