We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Find-replace in arrays / stopping crashes
Page Index Toggle Pages: 1
Find-replace in arrays / stopping crashes (Read 289 times)
Find-replace in arrays / stopping crashes
Dec 11th, 2007, 5:05am
 
First off, I know very little about programming in general. At all. So please bear with me.

I have a sketch that uses the Yahoo API processing library to take info put in a text box, search for it, and draw the summaries to the screen.

So far, so good.

However, I have a bug in the code - when the returned summary contains the word "index.gif", I get the following error, and the sketch stops:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I'm not entirely sure what's going on here (like I said, I'm not really a programmer at all), so I think the quickest way for me to solve this would be to simply add a space either side of the period. The drawn summaries are only for graphical effect, so this wouldn't have to big an impact.

My question - what's the easiest way to do a find/replace to an array containing text? Hope that's clear enough...and thanks Smiley

Re: Find-replace in arrays / stopping crashes
Reply #1 - Dec 11th, 2007, 5:37am
 
Hi. I can't help with the crash. Maybe if you give us a link to source code, we could see in detail what's wrong.

Anyway, for replacing string parts stored in an array, you can iterate the array and use Java String methods. They all are listed here :
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#method_summary

Have a look at replaceAll(), I think it can suit your needs.
Page Index Toggle Pages: 1