Regular Expression Q

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brad Everman

    #1

    Regular Expression Q


    Say I have an HTML file and want to convert all tags to lowercase, but
    leave the attributes alone. For instance:

    <SOME TAG ATTRIBUTE="Text THAT may be Upper"></SOME TAG>

    Needs to be converted to:

    <some tag attribute="Text THAT may be Upper"></some tag>

    I can easily convert everything in the tag to lower using '<.*?>' but am
    stuck getting PHP to ignore whatever is in quotes. Any ideas?

    Thanks.
  • bob.chatman@gmail.com

    #2
    Re: Regular Expression Q

    Have your tried parsing in two steps?

    1) grab the contents of the tags
    2) run the tags content through another regex that would lc everythign
    but whats in "here"?

    Bob

    Brad Everman wrote:
    Say I have an HTML file and want to convert all tags to lowercase, but
    leave the attributes alone. For instance:
    >
    <SOME TAG ATTRIBUTE="Text THAT may be Upper"></SOME TAG>
    >
    Needs to be converted to:
    >
    <some tag attribute="Text THAT may be Upper"></some tag>
    >
    I can easily convert everything in the tag to lower using '<.*?>' but am
    stuck getting PHP to ignore whatever is in quotes. Any ideas?
    >
    Thanks.

    Comment

    Working...