Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.
-
Koesper #1
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="<p>
line1
line2
</p>" 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="<p>';
dwquery += ' line1';
dwquery += ' line2';
dwquery += '</p>" 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="<p>thing1 thing2</p>" 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="<p>thing1 thing2</p>"
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
-
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,... -
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... -
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... -
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... -
telltarget doesnt work
Hello, I made a button in flash MX and did the following actionscript on it: on (rollover) { tellTarget ("MC") { gotoAndPlay(2); } } -
Joe Makowiec #2
Re: multiline dwquery doesnt work
On 07 Dec 2005 in macromedia.exchange.extensions.dreamweaver, Koesper
wrote:
Check the thread titled "Help With A Regular Expression And Line Breaks> 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.
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
-
Koesper #3
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
-
Koesper #4
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



Reply With Quote

