Results 1 to 4 of 4

Thread: Help newbie with Ragex (easy)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    19

    Help newbie with Ragex (easy)

    Hello

    i use such code for html strip
    Code:
    strOutput = Regex.Replace(InpData, "<[^>]*>", "")
    but i need to get rid of things like (all are in 1 string)

    Code:
    .thead a:link, .thead_alink
    (starts with dot ends with newline?)

    Code:
    a:hover, a:active, body_ahover
    (starts with character followed by ":" ends with newline?)

    i would like to use same method as above Ragex code but i have no idea how to work with it (its so complicated...).

  2. #2
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Help newbie with Ragex (easy)

    Do you mean you want to get rid of the entire stylesheet? You would do this, then:

    Code:
    strOutput = Regex.Replace(InpData, "<style[^>]*>.+?</style>", "")
    strOutput = Regex.Replace(strOutput, "<[^>]*>", "")
    Last edited by minitech; Jun 28th, 2011 at 04:23 PM.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    19

    Re: Help newbie with Ragex (easy)

    Im getting error something like

    System.ArgumentException was unhandled
    Message= analyzing "<style[^]*>.+?</style>" - Unterminated [] set.

    if i add > after ^ it appears to work but i still get this garbage in my text

    /do you know maybe some good tutorial with examples on how to use good Ragex syntax?

  4. #4
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Help newbie with Ragex (easy)

    Sorry, I guess I didn't press > hard enough fixed now.

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