Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to extrack string from a sentence?

how to extrack string from a sentence?

Scheduled Pinned Locked Moved C#
databasecomxmlhelptutorial
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wajans
    wrote on last edited by
    #1

    I have a string stored in a variable, say myString= <RssFeeds><link>http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml</link> <title>CodeGuru.com</title> <description>something</description></RssFeeds> <RssFeeds> <link>http://lifehacker.com/index.xml</link> <title>Lifehacker</title> <description>something</description></RssFeeds> I want to extract the text between <link> and </link> and also the text between <title> and </title> in two different arrays. How to do this, please help me. if anyone have code or any helpfull link please reply back. Thanks

    P S D J P 5 Replies Last reply
    0
    • W wajans

      I have a string stored in a variable, say myString= <RssFeeds><link>http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml</link> <title>CodeGuru.com</title> <description>something</description></RssFeeds> <RssFeeds> <link>http://lifehacker.com/index.xml</link> <title>Lifehacker</title> <description>something</description></RssFeeds> I want to extract the text between <link> and </link> and also the text between <title> and </title> in two different arrays. How to do this, please help me. if anyone have code or any helpfull link please reply back. Thanks

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      You could alway use regular expressions.

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      1 Reply Last reply
      0
      • W wajans

        I have a string stored in a variable, say myString= <RssFeeds><link>http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml</link> <title>CodeGuru.com</title> <description>something</description></RssFeeds> <RssFeeds> <link>http://lifehacker.com/index.xml</link> <title>Lifehacker</title> <description>something</description></RssFeeds> I want to extract the text between <link> and </link> and also the text between <title> and </title> in two different arrays. How to do this, please help me. if anyone have code or any helpfull link please reply back. Thanks

        S Offline
        S Offline
        soni uma
        wrote on last edited by
        #3

        Try using this way string myString = "http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml" + "CodeGuru.comsomething" + "http://lifehacker.com/index.xmlLifehackersomething"; string[] test = new string[15]; myString = myString.Replace("", "#"); myString = myString.Replace("", "#"); test = myString.Split(Convert.ToChar("#"));

        W 1 Reply Last reply
        0
        • S soni uma

          Try using this way string myString = "http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml" + "CodeGuru.comsomething" + "http://lifehacker.com/index.xmlLifehackersomething"; string[] test = new string[15]; myString = myString.Replace("", "#"); myString = myString.Replace("", "#"); test = myString.Split(Convert.ToChar("#"));

          W Offline
          W Offline
          wajans
          wrote on last edited by
          #4

          I want to extract substring and store it in an array from to , it repeats two times in my string. How to extract it?

          S 1 Reply Last reply
          0
          • W wajans

            I want to extract substring and store it in an array from to , it repeats two times in my string. How to extract it?

            S Offline
            S Offline
            soni uma
            wrote on last edited by
            #5

            You can doing it with using for loop.Check '<' in string array if array is not contain that than store that sting with ++

            1 Reply Last reply
            0
            • W wajans

              I have a string stored in a variable, say myString= <RssFeeds><link>http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml</link> <title>CodeGuru.com</title> <description>something</description></RssFeeds> <RssFeeds> <link>http://lifehacker.com/index.xml</link> <title>Lifehacker</title> <description>something</description></RssFeeds> I want to extract the text between <link> and </link> and also the text between <title> and </title> in two different arrays. How to do this, please help me. if anyone have code or any helpfull link please reply back. Thanks

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              Dirty but seems to work.

              string sFull = "this the is test for the true";
              string sToSearch = "the";
              int iFirst = sFull.IndexOf(sToSearch);
              int iSecond = sFull.IndexOf(sToSearch, iFirst + sToSearch.Length);
              string sText = sFull.Substring(iFirst + sToSearch.Length, iSecond - iFirst -sToSearch.Length);

              1 Reply Last reply
              0
              • W wajans

                I have a string stored in a variable, say myString= <RssFeeds><link>http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml</link> <title>CodeGuru.com</title> <description>something</description></RssFeeds> <RssFeeds> <link>http://lifehacker.com/index.xml</link> <title>Lifehacker</title> <description>something</description></RssFeeds> I want to extract the text between <link> and </link> and also the text between <title> and </title> in two different arrays. How to do this, please help me. if anyone have code or any helpfull link please reply back. Thanks

                J Offline
                J Offline
                J4amieC
                wrote on last edited by
                #7

                Thats not a string, its called "Xml" and there is built in ability to read its node values. Have a look at System.Xml.XmlDocument and System.Xml.XmlTextReader

                1 Reply Last reply
                0
                • W wajans

                  I have a string stored in a variable, say myString= <RssFeeds><link>http://www.codeguru.com/icom\_includes/feeds/codeguru/rss-all.xml</link> <title>CodeGuru.com</title> <description>something</description></RssFeeds> <RssFeeds> <link>http://lifehacker.com/index.xml</link> <title>Lifehacker</title> <description>something</description></RssFeeds> I want to extract the text between <link> and </link> and also the text between <title> and </title> in two different arrays. How to do this, please help me. if anyone have code or any helpfull link please reply back. Thanks

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  Yeah, XmlDocument.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups