Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help in searchin

 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to saerchin and was wondering what could i do to get familiar with it...in scjd what is it expected...normal checkin of databases or using regular expressions to get results......

please advice
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you could use regular expressions, if you are just using JTextFields in your search lookup. However, you will want to use JComboBoxes instead. Actually, that is kind of wrong, in that you can still use regular expressions , but in most cases the values in the JComboBox will be all the full values possible, and so you wouldn't need the regular expressions since you will have the whole string anyway.



Mark
 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Mark...

Would you able to provide me an example code snippet of a regular expression which can do searchin from textfields

Assuming the file is:

ID NAME LOCATION PRICE DATEOF ISSUe

now if i type in a name = "Fre"....i want all the names and their correspondin values begining with "FRE"

or suppose location = " LA"... or vice versa...
 
Jared Chapman
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Look at the Pattern class in the Java 1.4 API.

To find out if String myString begins with "Fre", you could do:
 
Jared Chapman
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

As of now I am using JTextFields. Just wondering what your reasoning is for using JComboBoxes is instead. I know they are a lot more convenient for the user, but as far as this assignment is concerned, aren't JTextFields good enough?
 
Jared Chapman
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and I almost forgot - congrats on #6000, Mark!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, actually I feel it is much easier to code that way. I believe that there are points regarding GUI and user interface, and providing a nice GUI for the operators that make it easier to use would get more points.

Abhi, actually AI don't use regular expressions, and never memorized the patterns for them and the two classes and methods that are used to run a regular expression on a String. Sorry.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic