From: fabsy Date: 2006-08-18T07:40:11+09:00 Subject: Re: reading website David Vallner skrev: > On Thu, 17 Aug 2006 23:55:05 +0200, fabsy wrote: > > > Aha! Yes it was something old. > > It opened the file with append.. > > > > And, sorry for all the questions.. (im really trying to learn) :) > > But is there any thing like this in ruby? > > > > --VB code-- > > > > If InStr(1, Text1.Text, "String to find", 1) > 0 Then Msgbox "I found > > the string!" > > > > -------- > > > > ( If InStr(Start,String1,String2,CompareMode)>0 Then Msgbox "I found > > the string!") > > > > > > Does VB index strings starting with 1? > > For very simple seaching, use String#include? > > >> "foobar".include? "ooba" > => true > > If you want to check if there's a substring to be found -after- (and not > including) the second character, for example, then I'd use a substring: > > >> "foobar"[2..-1].include? "ooba" > => false > > >> "foobar"[2..-1].include? "obar" > => true > > What VB's CompareMode is, I have no idea. Case sensitivity? If so, I'd > personally manually use String#downcase in the conditional. > > And, of course, there's always regular expressions, the swiss army knife > of string searching, but those are for a longer discussion and you can > probably find material for those out there that explains them rather > nicely. > > David Vallner Ok! But that doesn't tell me the position of the string.. Say that you have a textfile with the sentence "Could you pass me the milk please?" and I make a search for the string "milk". Then I want to know the position of where the search word starts so I can extract the word into a variable.... How do I do that? And yes VB index strings start with 1..