Results 1 to 4 of 4
Thread: Regular expression
- 10-26-2012, 02:45 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
Regular expression
Hi, all.
I have the brightest question of the month: how would I check my code for the list of string regular expressions? (I want to prevent the possibility of user asking question with unassigned symbols(
Here is the list, for example - the purpose is to ask the user "what do you want on your sandwich"
Then he is given the list, let's say, "ketchup", mayonnaise."
How would I prevent him from entering, let's say, "shoes", or just a bunch of numbers ....
I figured out it should be regular expressions, I still don't know how to incorporate it into my code. When I tried to solve the problem with boolean logics, the program crushed
for example, if customer should make one choice out of "no" and two ingredients ... I couldn't find a way to fix it.
so any ideas would be great.
Thanks.
- 10-26-2012, 03:54 PM #2
Re: Regular expression
I'm not sure how regular expressions would help you here.
If you have a finite amount of valid responses, add them all to a List. When the user enters a choice, make sure what they chose is in the List. If it's not, it's not a valid choice.
Or you could use a drop-down box JComboBox instead of having them enter free text, but that's only valid if you're using a GUI.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 10-26-2012, 05:03 PM #3
Re: Regular expression
Moved from Forum Guides
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 10-26-2012, 05:06 PM #4
Re: Regular expression
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Regular expression
By garnaout in forum New To JavaReplies: 4Last Post: 05-15-2012, 06:22 PM -
regular expression
By ehsansad in forum New To JavaReplies: 8Last Post: 03-18-2011, 02:23 PM -
Help with regular expression
By mr.ab18 in forum New To JavaReplies: 2Last Post: 08-06-2010, 10:01 PM -
regular expression
By QkrspCmptPop in forum Advanced JavaReplies: 8Last Post: 01-20-2010, 03:55 AM -
regular expression
By ras_pari in forum Advanced JavaReplies: 27Last Post: 10-07-2009, 12:25 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks