foob.*r matchs doesn't work

General discussions about Advanced Find and Replace
Post Reply
Posts: 2
Joined: Sat Feb 07, 2009 9:41 pm

foob.*r matchs doesn't work

Post by negevjeep » Sat Feb 07, 2009 10:03 pm

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 :

Site Admin
Posts: 1221
Joined: Mon Jan 31, 2005 5:32 pm

Re: foob.*r matchs doesn't work

Post by Abacre » Sun Feb 08, 2009 9:11 am

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.
Kind regards,
Abacre Limited

Posts: 2
Joined: Sat Feb 07, 2009 9:41 pm

Re: foob.*r matchs doesn't work

Post by negevjeep » Tue Feb 10, 2009 8:17 am

You are correct I did what you suggested and it worked. I thank you very much for your promt clear educational response.

Post Reply