multiline dwquery doesnt work

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default multiline dwquery doesnt work

    I'm building a new command, which is supposed to do a couple of automated
    find&replace actions (with regular expressions in some)
    But i've hit a snag, i can get a simple find&replace working (eg searching for
    "[ ]{2,}" and replacing them with " ", to get rid of multiple spaces)
    but as soon as i want to find a block of text (sourcecode spanning multiple
    lines) then i the command cannot locate the text to find.

    if i open the saved .dwt find&replace query directly in dreamweaver, it works.
    but when i build it into my command, then it doesnt anymore.

    any suggestions?

    i'm running dreamweaver 8 on a windowsXP machine.

    below you'll find:
    1: a sample of the text to be found&replaced
    2a: the contents of multiline.dwt
    2b: my non-working version of the multiline command
    3a: the contents of singleline.dwt
    3b: my working version of the singleline command.

    I hope someone can point out what i'm doing wrong..
    (i think it'll have something to do with line-breaks, but i havent found the
    solution yet...)

    Regards,
    Casper de Groot



    ################################################## ##########
    1: a sample of the sourcecode to be found&replaced
    ################################################## ##########

    multiline - change this:
    <p>
    line1
    line2
    </p>

    into this:
    <p>
    line1
    line1.5
    line2
    </p>


    singleline - change this:
    <p>thing1 thing2</p>

    into this:
    <p>thing1 thing1.5 thing2</p>

    ################################################## ##########
    2a: the contents of multiline.dwt
    ################################################## ##########

    <?xml version="1.0"?>
    <dwquery>
    <queryparams matchcase="false" ignorewhitespace="false"
    useregexp="true"wholeword="false"/>
    <find>
    <qtext qname="&lt;p&gt;
    line1
    line2
    &lt;/p&gt;" qraw="true"></qtext>
    </find>
    <replace action="replaceText" param1="<p>
    line1
    line1.5
    line2
    </p>" param2=""/>
    </dwquery>

    ################################################## ##########
    2b: my non-working version of the multiline command
    ################################################## ##########

    dwquery = '<dwquery>';
    dwquery += ' <queryparams matchcase="false" ignorewhitespace="false"
    useregexp="true"wholeword="false"/>';
    dwquery += ' <find>';
    dwquery += ' <qtext qname="&lt;p&gt;';
    dwquery += ' line1';
    dwquery += ' line2';
    dwquery += '&lt;/p&gt;" qraw="true"></qtext>';
    dwquery += ' </find>';
    dwquery += ' <replace action="replaceText" param1="<p>';
    dwquery += ' line1';
    dwquery += ' line1.5';
    dwquery += ' line2';
    dwquery += '</p>" param2=""/>';
    dwquery += '</dwquery>';

    dw.setUpComplexFindReplace(dwquery);
    dw.replaceAll(); //doesnt work!


    ################################################## ##########
    3a: the contents of singleline.dwt
    ################################################## ##########

    <?xml version="1.0"?>
    <dwquery>
    <queryparams matchcase="false" ignorewhitespace="false"
    useregexp="true"wholeword="false"/>
    <find>
    <qtext qname="&lt;p&gt;thing1 thing2&lt;/p&gt;" qraw="true"></qtext>
    </find>
    <replace action="replaceText" param1="<p>thing1 thing1.5 thing2</p>"
    param2=""/>
    </dwquery>

    ################################################## ##########
    3b: my working version of the singleline command.
    ################################################## ##########

    dwquery = '<dwquery>';
    dwquery += ' <queryparams matchcase="false" ignorewhitespace="false"
    useregexp="true"wholeword="false"/>';
    dwquery += ' <find>';
    dwquery += ' <qtext qname="&lt;p&gt;thing1 thing2&lt;/p&gt;"
    qraw="true"></qtext>';
    dwquery += ' </find>';
    dwquery += ' <replace action="replaceText" param1="<p>thing1 thing1.5
    thing2</p>" param2=""/>';
    dwquery += '</dwquery>';

    dw.setUpComplexFindReplace(dwquery);
    dw.replaceAll(); //works!

    Koesper Guest

  2. Similar Questions and Discussions

    1. Help my flashplayer doesnt work
      Hey there, i desperately need help, no websites that have flash programmes will work on my internet as it says i need the latest flash player,...
    2. Flash Doesnt Work
      I had Macromedia Flash 7 before which worked perfectly fine. Then some websites stopped working and told me to get Macromedia Flash 7(which I...
    3. Work Wrap (Multiline Dynamic Text)
      Hi I had faced this problem when using this text "Lorum Ipsum Dolar (May 2003)" and after replaced this text with any other text the problem was...
    4. CDONTS doesnt work always
      I am using CDONTS to send mail to the user from my ASP application. However, the code doenst works all the time. I am able to get mails but nothing...
    5. telltarget doesnt work
      Hello, I made a button in flash MX and did the following actionscript on it: on (rollover) { tellTarget ("MC") { gotoAndPlay(2); } }
  3. #2

    Default Re: multiline dwquery doesnt work

    On 07 Dec 2005 in macromedia.exchange.extensions.dreamweaver, Koesper
    wrote:
    > I'm building a new command, which is supposed to do a couple of
    > automated find&replace actions (with regular expressions in some)
    > But i've hit a snag, i can get a simple find&replace working (eg
    > searching for "[ ]{2,}" and replacing them with " ", to get rid of
    > multiple spaces) but as soon as i want to find a block of text
    > (sourcecode spanning multiple lines) then i the command cannot
    > locate the text to find.
    Check the thread titled "Help With A Regular Expression And Line Breaks
    Using PHP" from December 2 in
    [url]news://forums.macromedia.com/macromedia.dreamweaver[/url]

    In particular, check Gary White's response about multiline mode for
    regular expressions, and see if that helps.

    [url]http://groups.google.com/group/macromedia.dreamweaver/browse_frm/thread[/url]
    /b6caa2dedcda6792/f00bf573a60b19f5?
    lnk=st&q=regular+expression+line+group%3Amacromedi a.*&rnum=1
    &hl=en#f00bf573a60b19f5

    which reduces to:

    [url]http://tinyurl.com/7d3ty[/url]

    --
    Joe Makowiec
    [url]http://makowiec.net/[/url]
    Email: [url]http://makowiec.net/email.php[/url]
    Joe Makowiec Guest

  4. #3

    Default Re: multiline dwquery doesnt work

    I finally had the chance today to tinker with my shiny new command again, and
    i've looked into Joe's suggestion.
    The thread he linked to is about a reg-ex in php, not dreamweaver. so i'm a
    little bit confused why this can be helpfull.

    one of the suggestions in that tread was using multiline mode in the
    preg_replace() function, but that option isnt available in dreamweaver.

    i did figure out that if i use dw.showFindDialog() that it is easier to debug,
    since i then can see what the dreamweaver had made of the dwquery i want to run.

    I have now confirmed that the problem is linebreaks, so if you just add a \n
    after each line the problem is solved.

    The command still has some issues, so i'm not happy yet, but atleast we're
    getting somewhere!

    Koesper Guest

  5. #4

    Default Re: multiline dwquery doesnt work

    It still doesnt work as i want it to...

    I want it to three consecutive find&replace actions, and i've gotten all of
    them to work individually, when i use the dw.showFindReplaceDialog() thing.
    but when i use them individually with a dw.replaceAll() then they dont work
    anymore.

    Also when i try to use them consecutively, it doesnt work, because the user
    has to press 'replace all', but cant because then the next find&replace is
    already set up. Is it possible to have the javascript wait for input. But
    without blocking the userinterface?
    (if you stop the script by an alert(), it is no longer possible to click the
    FindReplaceDialog, since the alert screen takes the focus)

    Any suggestions?
    This thing has taken so much time already (and i really think it can be a time
    saver in the long run), so i reaaaaalllyyy want it to work... it would be such
    a shame to let it go to waste...

    Koesper Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139