Page 1 of 1

foob.*r matchs doesn't work

Posted: Sat Feb 07, 2009 10:03 pm
by negevjeep
I have 4.2 version and trying to do basic match operation and it doesn't work.
I have 100 files which I want to delete the following line :

<A href="../english/*.html">

What I want ot do is delete the line where the * is a differnt string in each file
<A href="../english/about.html">
<A href="../english/new.html">

I want to find them with:
<A href="../english/*.html">

FYI in this respect a simple match doesn't work like find :

Re: foob.*r matchs doesn't work

Posted: Sun Feb 08, 2009 9:11 am
by Abacre
You are misusing syntax of regular expressions.

In Windows for file find operation everyone knows that we can use ? and * chars to search files with mask. So ? means any char and * means any number of any chars.

In Advanced Find and Replace we use another engine for regular expressions, we are using industry-standard Perl-style regular expressions. The syntax is described here.

So instead of ? you should use . which is any char.
And * means any number of chars. Thus you have to use .* combination (this replaces Windows-line *).
Your text already has . chars. Thus you have to escape it with preceding \ char.

Therefore, do the following:
Go to Batch Replace tab.
Check "Use Regular Expressions" option.
Put into Search For:
<A href="\.\./english/.*\.html">
Replace With field should be empty.

That's all.

But you said you want to delete line containing the text. Line also has end of line chars.
In Windows using Perl-style regular expressions end of line should be denoted as \r\n

Thus if your text occupies whole line and you want to remove the line, the Search For should be:
<A href="\.\./english/.*\.html">\r\n

^ means start (the beginning) of the line. Thus the more exact regular expression should be:
^<A href="\.\./english/.*\.html">\r\n

That's all.

Note: in AFR you can use Regular Expressions Builder located on Batch Replace tab to check and test your regular expressions.

Re: foob.*r matchs doesn't work

Posted: Tue Feb 10, 2009 8:17 am
by negevjeep
You are correct I did what you suggested and it worked. I thank you very much for your promt clear educational response.