• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt regarding indexof or regex  RSS feed

 
Madhumitha Baskaran
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!