• 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

Doubt regarding indexof or regex

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What algorithms are used by indexof() or regex in java.Please tell me.

I am looking for 2 easy algorithms to implement string match. Can you suggest that also.

As tomorrow is my project deadline, I am not able to understand complex algorithms easily.

Please help.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Madhumitha Baskaran wrote:What algorithms are used by indexof() or regex in java.Please tell me.


I don't understand the question, but the difference is that indexOf() is a straightforward character-for-character matcher, whereas regex is a pattern matcher.

I am looking for 2 easy algorithms to implement string match. Can you suggest that also.


indexOf() is definitely simpler than using regexes.

As tomorrow is my project deadline, I am not able to understand complex algorithms easily.
Please help.


1. If you can learn regexes in 24 hours you should be on the board of Mensa, so unless that's the case I'd stick with indexOf().
2. Next time, don't wait until the last minute to ask for help.

Winston
 
Madhumitha Baskaran
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wanted some string match algorithm like Boyer moore algorithm. I just wanted to know if index of or regex functions use any of the standard string match algorithm. Can you help me with naming any easy string match algorithm. Boyer moore algorithm is so complex considering that I have less time. Please help
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Madhumitha Baskaran wrote:I wanted some string match algorithm like Boyer moore algorithm. I just wanted to know if index of or regex functions use any of the standard string match algorithm. Can you help me with naming any easy string match algorithm. Boyer moore algorithm is so complex considering that I have less time. Please help


The simplest algorithm, as I've already told you, is indexOf(), and it works exactly as you would expect and takes O(s1 * s2) time. The only other one I know of other than Boyer Moore (of which there is also the Horspool variant) is Knuth's KMP algorithm; however, you've left it rather late to write a working method that uses either B-M or KMP, so you'd better start now.

Winston
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic