www.webdeveloper.com
Results 1 to 1 of 1

Thread: Need to match last occurrence of one of two characters with regular expression

Hybrid View

  1. #1
    Join Date
    Nov 2006
    Posts
    84

    Need to match last occurrence of one of two characters with regular expression

    I need to match last occurrence of one of two characters with regular expression. In this instance it's either a semi-colon or the close of a comment.

    Consider the string:

    Code:
    body {
    /* background-image:url('http://www.example.com/image.jpg'); */
    height:100%;
    width:100%;
    }
    My goal is to match each CSS property regardless of whether it is commented-out or not. The trouble is, I'm not sure how to write a pattern that would match both normal properties ending with semi-colons and properties that have been commented-out. I'm open to using PHP if it makes it easier.

    The pattern below isolates each property but picks up on the semi-colon only, not the close of a comment.

    Code:
    /[^{]*?;/
    Any help is appreciated, thank you!
    Last edited by robmarston; 08-15-2012 at 02:18 PM. Reason: Typo

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles