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. Web Development
  3. style property regular expression

style property regular expression

Scheduled Pinned Locked Moved Web Development
regexcsharphtmlcomtutorial
5 Posts 3 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.
  • L Offline
    L Offline
    L Viljoen
    wrote on last edited by
    #1

    Hi to all I would like to search a html document file for all the style properties and loop through them for example if i have the code :

    I want the regular expression to pick up the following text style="color:#fff" style="text-align:center" I want to get the amount if hits it found and then I should be able to loop through it. Sorry this is probably a noob question but havent used regex for 2 years C# code please Thanx Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com

    S 1 Reply Last reply
    0
    • L L Viljoen

      Hi to all I would like to search a html document file for all the style properties and loop through them for example if i have the code :

      I want the regular expression to pick up the following text style="color:#fff" style="text-align:center" I want to get the amount if hits it found and then I should be able to loop through it. Sorry this is probably a noob question but havent used regex for 2 years C# code please Thanx Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com

      S Offline
      S Offline
      sph3rex
      wrote on last edited by
      #2

      style[\s]*=[\s]*"([a-z0-9\s;:]+(?!=[>"])) i presume you can write c# code

      Code? Yeah i love it fried together with a glass of wine.

      L 1 Reply Last reply
      0
      • S sph3rex

        style[\s]*=[\s]*"([a-z0-9\s;:]+(?!=[>"])) i presume you can write c# code

        Code? Yeah i love it fried together with a glass of wine.

        L Offline
        L Offline
        L Viljoen
        wrote on last edited by
        #3

        Thanx Yes i will be able to take it from here

        Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com

        P 1 Reply Last reply
        0
        • L L Viljoen

          Thanx Yes i will be able to take it from here

          Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com

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

          I'd like to add that you should take a look at the Expresso tool found on this site for working with regular expressions. In case you have more regular expressions to work with, you may find it very useful :-D

          "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 "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

          L 1 Reply Last reply
          0
          • P Paul Conrad

            I'd like to add that you should take a look at the Expresso tool found on this site for working with regular expressions. In case you have more regular expressions to work with, you may find it very useful :-D

            "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 "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

            L Offline
            L Offline
            L Viljoen
            wrote on last edited by
            #5

            also I found that this code style[\s]*=[\s]*"([^"]+(?!=[>"]))["] works a bit better as the previous code cut off the style code at "-" characters

            Le Roux Viljoen Web Developer PCW New Media South African Branch www.pcwnewmedia.com

            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