• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String.toLowerCase()

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have film titles that begin with the name of the film followed by ",The" if the original name begins with the. Example: Village, The
When a user wants to search the collection for a film title, he or she will naturaly type in The Village, so I have some code that switches the word The around, then switches it back to see if the title is in the collection. My variable "the" holds the literal The which is capitalized, but the user may enter the, uncapitalized. Is there an ingenious way to use toLowerCase() somewhere in my code to catch both possibilites?

key: is the a HashMap key representing a film title.
title: is the String recieved via the TextField
the: is "The "

 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep what the user enters, to use in messages to the user,
but convert everything the user enters to uppercase and
work entirely within uppercase:

[ October 19, 2005: Message edited by: Jeff Albrechtsen ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you've ironed out case differences, look at String.startsWith() or indexOf(). You probably only want to modify titles when the user enters "The Chase" and not "O Brother Where Art Thou"
reply
    Bookmark Topic Watch Topic
  • New Topic