I could, but the beginners forum is a 'you give it a go first, we'll correct it'
look up the regex package (or google java regular expression)
common gotcha is the escape character \ often is required as \\
If regular expressions are a bit beyond your grasp at this point, just do it the old-fashioned way. What steps would you go through to accomplish this task?
If you have a hard time starting with that, let's approach it from a more real-world direction: You have a bowl full of beans with some stones mixed in with them. What steps would you use to end up with a bowl full of beans but no stones?
David Crane wrote:I had thought the method you use was related to booleans ...
Again, that mystifies me. Booleans represent the values true or false. Nothing to do with stripping characters.
how do I do that in code
No one's going to write it for you. Start with how would you do it not in code. Write down the steps. Then try to see if you can write the code to follow those steps.
Bear Bibeault wrote:Nothing to do with stripping characters.
Or phone numbers, which actually confused me even more.
(Okay, I get a lot of false phone numbers, but my dating life is none of your business.)
What kinds of characters are you trying to remove? Have you considered replacing those characters with an empty string? If you look at the java.lang.String API you might find some methods for doing just that.
David Crane wrote:yes, I do want a bowl of beans, how do I do that in code
I think that you mssed the point entirely. Bear is suggesting that you do it without a computer first. Understand the process. And then translate it to code.
If you understand the process (with a physical pile of beans), then you'll understand how to do that in code.
David Crane wrote: I had thought the method you use was related to booleans, so I am grateful for the assitance
Here is something that may help you... Besides conditions (as if using the "if", "for", or "while" keyword), which probably applies to all programs. Looking into Booleans is a red-herring. Don't waste any more time on it.
David Crane wrote:I would give it a go, the problem is I don't know how
I have my string in a boolean form now
what I can't figure out is how to tell it to remove non-numeric characters
First of all.....
boolean can not OR will not OR like NEVER have values other than true or false.
Secondly, what do you mean by "I have my string in a boolean form"?