#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Finding all content incl. returns between 2 phrases..?


    I want to use a regular expression that will find all content between a defined start and end phrase such as between </title> and </head> or between <!-- and --> for comments.

    Any combination of spaces, new lines, returns and any symbols, numbers and letters could occur between the defined start and end phrases that i mentioned above. So I only want the find to stop if it encounters that phrase in its entirety. I want the start and end phrase included in the replace operation.. So i can alter them too if necessary.

    This is for use in Dreamweaver's Find and Replace.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    I tried using (.*?) between the tags and it isn't catching new lines.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    your DreamWeaver needs to support either non-greedy quantifiers or negative lookahead assertions. If it doesn't, you're out of luck.

    The pattern for non-greedy quantifiers would be
    Code:
    </title>.*?</head>
    You might need to turn on some "multi line" mode to make the dot match the newline characters. If that's not possible, use [.\r\n] instead.

    You should also add optional whitespace within the tags to make them more robust.

    Note that regexes aren't made for complex languages like HTML. If you need your replacements to, for example, respect the element nesting, forget that DreamWeaver stuff and grab an actual HTML parser.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    Originally Posted by Jacques1
    If that's not possible, use [.\r\n] instead.
    Code:
    (.|[\r\n])

IMN logo majestic logo threadwatch logo seochat tools logo