Skip navigation
Doigy
Currently Being Moderated

Find & Replace : Delete before tag

Dec 9, 2006 6:23 AM

Hi,

Do you know of a way using Dreamweaver to delete html code before a known tag in the page ?

Thanks,

Steve
 
Replies
  • Currently Being Moderated
    Dec 9, 2006 7:03 AM   in reply to Doigy
    Find:
    <div id="field><img src="mypic.jpg" alt="big pic" width="3364" height="2548" id="background_image" /><p>The little boy and his dog ran through the field.</p></div>

    Replace:
    <div id="field><p>the field.</p></div>

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2006 4:25 AM   in reply to Excavatorak
    Doigy wrote:
    > Using your example, I want to delete everything in the page before
    > <div id="field>
    >
    > I was thinking there may be an extension that was reasonably well known.

    What you're seeking to do is not as simple as you seem to think it
    should be. The way to do it is to use a regular expression. If the tag
    you're looking for is guaranteed to begin <div id="field", then a simple
    regex will work. If there are any other attributes before the id, or if
    the quotes around field might be missing, it becomes more complex.

    That said, if you want to remove absolutely everything, including the
    DOCTYPE and head, put this in the Find field:

    [\w\W]+<div id="field"

    In the Replace with field, use this:

    <div id="field"

    If you want to remove only everything from the opening body tag, use
    this instead:

    <body>[\w\W]+<div id="field"

    In the Replace with field, use this:

    <body><div id="field"

    Make sure there's a check mark in the Use regular expression checkbox,
    and click Replace.

    --
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2006 7:35 AM   in reply to Newsgroup_User
    Doigy wrote:
    > Brilliant, thanks David.
    >
    > For anyone following, there's a reference to regular expressions http://www.adobe.com/devnet/dreamweaver/articles/regular_expressions_0 3.html

    Glad it did the trick for you. Regular expressions can be quite tricky,
    but they're also extremely useful.

    --
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 11, 2006 4:13 AM   in reply to Doigy
    Doigy wrote:
    > What I need to do now is to use this command on about 600 different files. I'm
    > running a 1Ghz Celeron with 350MB of RAM, and it's not coping that well.

    I'm not surprised it's having difficulty. The minimum required for
    Dreamweaver is 256MB of RAM, and 1GB is recommended if you have another
    Studio program running simultaneously. I suggest that you close down all
    other programs, temporarily disable virus scanning, and try a folder at
    a time. Experiment to find the optimum number of files to process at one
    time.

    The ideal way of handling this would be with Perl, which is designed to
    do this sort of batch management of text files. Unfortunately, Perl
    tends to cause severe brain damage to anyone trying to learn it. Unless
    you can find a Perl expert to help you, you're likely to be stuck doing
    just a few files at a time.

    --
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points