SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: ReGex Question

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ReGex Question

    ok i have a list of domains

    for example

    dogstoday.com
    catstoday.com
    petstoday.com
    dogsnow.org
    dogsabc.net
    catlitter.info

    i want a regex that will give me all domains that has the word i specify for example dogs or cats

    if i give dogs it should return

    dogstoday.com dogsnow.org dogsabc.net

    can any one tell me how to do this in c# ?

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I'm not exactly sure you need a regular expression for this.

    Consider the following
    Code C#:
    			string[] listOfItems = { "dogchain", "catchain", "doghead", "cathead", "fancydog", "fancycat" };
     
    			foreach (string item in listOfItems)
    			{
    				theReturn.Text += item.IndexOf("dog") != -1 ? String.Format("{0}<br />",item) : "";
    			}


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •