1

I'd like to know how can i find out if a substring is contained in another string? In VB.net I used to write something like:

Dim s as string = textbox1.text
if s.contains("http://youtube.com/watch?v=")
   //instructions
end if

Basically, this is want I want to do but it doesn't work the same way in RealBasic, so how can I translate this?

Paul Lefebvre
  • 6,253
  • 3
  • 28
  • 36
  • 2
    @zimmryan Your comment is out of line. First of all, RegEx is surely not the right solution as it's much more CPU intensive because of its powers, and also because it's much more complicated to use (one has to think of escaping and whatnot). Furthermore, StackExchange is made for these kind of questions, in order to have it all in one place, and for allowing others to provide alternatives. It's not your server space, so you have no business in criticising. – Thomas Tempelmann May 07 '13 at 22:09
  • Apologies if the comment came across as offensive. I was simply going by the statement provided by SO that says a question should show research effort. Meant it as constructive, and to say that I did not spend much time googling, but came across a few things that may help. – zimmryan May 08 '13 at 01:56

1 Answers1

3

You can do the same thing by using:

Dim s as string = textbox1.text    
if s.instr("http://youtube.com/watch?v=") > 0 then
   //instructions
end
BKeeney Software
  • 1,299
  • 6
  • 8