Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Searching  RSS feed

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

findByCriteria method comments:
* Returns an array of record numbers that match the specified
* criteria. Field n in the database file is described by
* criteria[n]. A null value in criteria[n] matches any field
* value. A non-null value in criteria[n] matches any field
* value that begins with criteria[n]. (For example, "Fred"
* matches "Fred" or "Freddy".)

My Question:
For the search "matches any value that begins with...", should I use regular expressions or will the String Object method "startsWith" be sufficient?

Thanks,
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Wickes Potgieter:
Hi,

findByCriteria method comments:
* Returns an array of record numbers that match the specified
* criteria. Field n in the database file is described by
* criteria[n]. A null value in criteria[n] matches any field
* value. A non-null value in criteria[n] matches any field
* value that begins with criteria[n]. (For example, "Fred"
* matches "Fred" or "Freddy".)

My Question:
For the search "matches any value that begins with...", should I use regular expressions or will the String Object method "startsWith" be sufficient?

Thanks,



startsWith is the perfect method for it. In fact, I am going to use it exclusively and not check for exact matching. Exact matching will happen as a special case of using this method.

I am also going to implement criteria[n] as a mirror for the String[] array for the record. So most of the values will always be null.
[ August 15, 2004: Message edited by: Anton Golovin ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!