Page 1 of 1

I can do this in Dreamweaver

Posted: Mon Mar 20, 2006 3:38 pm
by Mart
Ok in dreamweaver search and replace I can write a regular expression and not replace something that is found. Can I do this in adv. search and rep.

For instance I find this reg ex
\n([0-9])

and as I have the 0-9 in brackets I can use it in the replace so that it does not replace that char for instance
$1

this will replace the \n with a space and leave the numeric character alone.

Can I do this in . search and rep.

Posted: Mon Mar 20, 2006 7:10 pm
by Abacre
Yes, this regular expression will work with Advanced Find and Replace
too. It's called "Perl-style regular expressions".
Read more about supported r.e. syntax:
http://www.abacre.com/afr/manual/regexpsyntax.htm

But with Advanced Find and Replace you can do much more:
for example you may specify Batch grid of expressions.
and you may use "Modifier E" which means "evaluate expressions".
Read the page:
http://www.abacre.com/afr/manual/evaluation.htm

So, for example, <%=Lower($1)=%> will convert found text into lower
case.

Can do this in DW

Posted: Tue Mar 21, 2006 9:00 am
by Mart
Ok I have been giving it a go. But not getting any results. I have done the following have I missed anything out?

I have gone to Action > Options > Batch Replace and ticked regular expressions, Modifier E, no other modifiers are clicked.

Then in the batch processor screen I have this:
use regular expressions is ticked
search for: \r\n([0-9]{5}),\r\n([0-9]{5})
replace with: +++<%=$1,$2=%>

The result I get is Found 0 files of one in 63ms. Which

I am pointing to a directory which contains one txt file, mask I have set to txt. I execute and it returns none found, In DW this finds an occurance every 4th line, which is correct. Is the syntax different in AFD for the reg ex or?

cheers
Martin

Posted: Tue Mar 21, 2006 10:59 am
by Abacre
The syntax is the same. But why do you use Modifier E in your case?
For Replace With you should simply use
+++$1,$2
That's all.

Done in DW

Posted: Tue Mar 21, 2006 11:31 am
by Mart
Thanks for the prompt, I can see that now, although it still does not explain why my find reg ex does not find and results when in DW it finds thousands.

I have tried the following:
\r([0-9]{5}),\r([0-9]{5})

\n\r([0-9]{5}),\n\r([0-9]{5})

\n([0-9]{5}),\n([0-9]{5})

Still comes back with no matches. Is there something wrong or missing in my reg ex. As I say Dreamweaver returns loads of results.

Posted: Tue Mar 21, 2006 11:49 am
by Abacre
The correct expression for your case is:

Search for:
\r\n([0-9]{5}),\r\n([0-9]{5})

Replace with:
+++$1,$2

We verified: it works great.
For Windows files you should use \r\n as line separator.
If it still does not work on your computer send us one sample file to
support@abacre.com we will send you then correct configuration file.

Works in DW

Posted: Tue Mar 21, 2006 11:52 am
by Mart
Yeah I tried that myself in the interim, works here too, thanks for the help.

Looking at the Reg ex manul for ADF though I cannot find what would be the equivalent of [:blank:] to match tabs and spaces, in DW I can use this [ ] does it work the same?

thanks for your help.

cheers
Martin

Posted: Tue Mar 21, 2006 12:02 pm
by Abacre
Read the documentation more carefully:
http://www.abacre.com/afr/manual/regexpsyntax.htm

\s any space (same as [ \t\n\r\f])

Can do in DW

Posted: Tue Mar 21, 2006 4:14 pm
by Mart
Ok one final thing that I can do in Dreamweaver but not in AFR, from what I can find is this:

I wish to replace all occurances of +++ with a carriage return. I can do this in DW by doing a CTRL+ENTER in the replace field. I tried this in the Batch replace and it did nothing, I also tried \r\n in the replace but it just replaced everything with \r\n.

Ideally I want the carriage returns to be Unix ok, it is for Oracle SQL data so I am guessing that this may get upset with the windows \r\n too.

Thanks for reading, and the help so far, and I hope someone can help with this problem.

cheers
Martin

Posted: Tue Mar 21, 2006 4:45 pm
by Abacre
In Batch replace tab you may use \r\n or \r
It works. But you should check "Use regular expressions" before
using \r\n.

Otherwise use Replace tab which may include multi-line text. But r.e.
are not allowed yet on Replace tab.