5 Replies - 35563 Views - Last Post: 11 May 2009 - 03:44 AM Rate Topic: -----

#1 eviltoaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-May 09

find word in string

Posted 10 May 2009 - 04:23 AM

if I have a string "dream in code" and want to find the "dream" word, but i don't know where it is in the string

how and wish functions do i need to use?
Is This A Good Question/Topic? 0
  • +

Replies To: find word in string

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: find word in string

Posted 10 May 2009 - 04:34 AM

please past you code
:code:
just for helping you:
first make an array string then use split and loop function.
Was This Post Helpful? 0
  • +
  • -

#3 papuccino1  Icon User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: find word in string

Posted 10 May 2009 - 07:14 AM

Maybe this link will help you.

http://tinyurl.com/qkepxb
Was This Post Helpful? 0
  • +
  • -

#4 lesPaul456  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 173
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: find word in string

Posted 10 May 2009 - 10:14 AM

You can use regular expressions. Read about them here.
Was This Post Helpful? 0
  • +
  • -

#5 TommyBoy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-May 09

Re: find word in string

Posted 10 May 2009 - 11:37 AM

I believe you can always use the IndexOf() method.

string myText = "dream in code";
int positionOfDream = myText.IndexOf("dream");


This will give you the position of the first instance of the word "dream" within your string.

Hope that helps.

Tom
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: find word in string

Posted 11 May 2009 - 03:44 AM

string test1 = "dream in code";
string test 2 = "dream";

if (test1.Contains(test2))
{
     // some code when "dream" is in "dream in code"
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1