Results 1 to 4 of 4

Thread: String Retrieval

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    String Retrieval

    I have a string like this:

    font-family:Arial;font-size:10px;color:green;

    I would like to retrieve the string like this:
    Arial;10px;green

    How do I accomplish this ?

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: String Retrieval

    Do you use regular expressions or would string functions be better?
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: String Retrieval

    Hello,

    Am I right in saying that you are parsing HTML that you are getting from "somewhere"?

    If so, you might want to take a look at the HTMLAgilityPack:

    http://htmlagilitypack.codeplex.com/

    Which I am fairly sure has methods for getting at this data.

    Gary

  4. #4
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: String Retrieval

    You can use Regular expressions for your purpose. This is possible both ways - javascript as well as server side asp.net code, since both support Regular experessions in one form or the other.

    The following Regex expression will help get you the relevent parts:
    Code:
    (?<=:).+?(?=;)
    Here's the strategy:
    Use the regex expression I provided above to get the required parts. You will obviously get them in separate groups/sub-groups. All you need to do after that is to join/concatenate them with a semi-colon in between.

    Let me know if you need some sample code and I'll try to quickly construct one.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

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



Click Here to Expand Forum to Full Width