I have a problem where I am trying to search for a substring in string. That substring may or may not be in the string.
str = "hello how are you?"
substr = "how are"
Two ways which I know if can be done are:
string.indexOf("how are")
- regex
But, is there any other "optimized" way? What would you have done?
Can Ruby provide a better answer? Since we use jRuby the answer can be in Ruby or Java.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…