wildvards....

General discussions about Advanced Find and Replace
Post Reply
papamark

wildvards....

Post by papamark »

Hello, is it possible with afr to replace just one number like:


mapout05251=90101305251 where 05251 is the varialble that should stay ?

Means, I have plenty of files where this is constant

Mapout*****=01013***** and need to change to Mapout****=01019*****

**** means in one file 05251, in the next 05255, 05255 and so on?
Is it possible to keep the variable and only change the constanly number?
That would be a great thing

papamark

wildcards

Post by papamark »

Hello Roman

to make it more clear, I need to find

[07:00] Mo Di Mi Do Fr
MapOut02=90107102
MapOut03=90107103
MapOut04=90107104
MapOut05=90107105
MapOut06=90107106
MapOut07=90107107
MapOut08=90107108
MapOut09=90107109
MapOut07031=90101907031

These are changing from file to file
MapOut0****=9010190**** , starting with 0 and 2 or 3 or 4 numbers
I need to change it in this way:

[07:00] Mo Di Mi Do Fr
MapOut02=90107102
MapOut03=90107103
MapOut04=90107104
MapOut05=90107105
MapOut06=90107106
MapOut07=90107107
MapOut08=90107108
MapOut09=90107109
MapOut07031=90101307031

Means, I need to change MapOut0****=9010190**** to
MapOut0****=9010130****

And need the lines above as well. Is that possible with ADF ?
That raelly would be a great thing!

Greetings, Mark

papamark

mark

Post by papamark »

It looks like AFR is not able to do the Jop like requiered.
That is the difference between shareware and a full product:
Bad written manuals and halftime support. You guys should
think about to write full proper manual. It is very difficult to understand where are you using wildcards and what is text to be replaced. It would be more helpfull for example to work with colours or cursiv texture.
Also I have found out that afr is not able to find text that is underlined or that is part of Document-Feet.

At least this peace of software is a nice try and a step in the right direction but miles away from a proffesional Version for Sales, so that we are not going for buy it.

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

Post by Abacre »

Hi,

In manual it's clearly stated what with wildcards (regular
expressions) it's possible to make almost any kind of search and
replace. But sure some intelligence (brain shake) is needed to find
out a solution.

Your case is not an exception.

Suppose we have the following source code:

[07:00] Mo Di Mi Do Fr
MapOut02=90107102
MapOut03=90107103
MapOut04=90107104
MapOut05=90107105
MapOut06=90107106
MapOut07=90107107
MapOut08=90107108
MapOut09=90107109
MapOut07031=90101907031


And we after replace we want to get the following resulting code:

[07:00] Mo Di Mi Do Fr
MapOut02=98767102
MapOut03=98767103
MapOut04=98767104
MapOut05=98767105
MapOut06=98767106
MapOut07=98767107
MapOut08=98767108
MapOut09=98767109
MapOut07031=98761907031


So in this example 90107 is a fixed part that should be replaced by
9876. Simply speaking replace MapOut***=90107**** by MapOut***=9876****

The solution (in terms of regular expressions) is:

Search for:
MapOut(\d+)=9010(\d+)

Replace with:
MapOut$1=9876$2

I verified it perfectly works.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

papamark

Wildcard

Post by papamark »

Hello Roman and thanks for your reply.
It works, if I use Batch Replace with marked -use regular expression- field.

But the quetsion was not to identify a single line with text.
What I need to find is a full Block.
For example we have to Blocks like this:

[00:00] Mo Di Mi Do Fr
MapOut02=90107002
MapOut03=90107003
MapOut04=90107004
MapOut05=90107005
MapOut06=90107006
MapOut07=90107007
MapOut08=90107008
MapOut09=90107009
MapOut05963=90101305963

and

[19:00] Mo Di Mi Do Fr
MapOut02=90107002
MapOut03=90107003
MapOut04=90107004
MapOut05=90107005
MapOut06=90107006
MapOut07=90107007
MapOut08=90107008
MapOut09=90107009
MapOut05963=90101305963

Now I only want to change the last line ot the second block.
The line self is simular to the last line of the second block

Means, I am looking for a way to work with wildcards in the last lines
and indetify the block by the first line of this block:

[19:00] Mo Di Mi Do Fr
MapOut02=90107002
MapOut03=90107003
MapOut04=90107004
MapOut05=90107005
MapOut06=90107006
MapOut07=90107007
MapOut08=90107008
MapOut09=90107009
MapOut****=901013****

changing into

[19:00] Mo Di Mi Do Fr
MapOut02=90107002
MapOut03=90107003
MapOut04=90107004
MapOut05=90107005
MapOut06=90107006
MapOut07=90107007
MapOut08=90107008
MapOut09=90107009
MapOut****=901019****

without touching this:

[00:00] Mo Di Mi Do Fr
MapOut02=90107002
MapOut03=90107003
MapOut04=90107004
MapOut05=90107005
MapOut06=90107006
MapOut07=90107007
MapOut08=90107008
MapOut09=90107009
MapOut****=901013****

Is this possible with AFR ? That would be the perfect solution.Of course I`ve read the manual, but at least I cannot find a way to do it like discriebed.

Greetings Mark

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

Post by Abacre »

I think it's also possible. Is number of lines in block is fixed?

MapOut02 ... MapOut09 So do we always have 02..09?

Is the last line of the block is also last line of the file?

You may put whole block into Batch replace (sure "Use regular expressions" on Batch replace tab should be selected).

For example:

Seacrh for:
\[19:00\] Mo Di Mi Do Fr\r\nMapOut02=90107002\r\nMapOut02=90107002\r\nMapOut03=90107003\r\nMapOut04=90107004\r\nMapOut05=90107005\r\nMapOut06=90107006\r\nMapOut07=90107007\r\nMapOut08=90107008\r\nMapOut09=90107009\r\nMapOut(\d+)=901013(\d+)

Replace with:
\[19:00\] Mo Di Mi Do Fr\r\nMapOut02=90107002\r\nMapOut02=90107002\r\nMapOut03=90107003\r\nMapOut04=90107004\r\nMapOut05=90107005\r\nMapOut06=90107006\r\nMapOut07=90107007\r\nMapOut08=90107008\r\nMapOut09=90107009\r\nMapOut$1=901019$2

Here is \r\n is new line + return chars.

But it's better to use different techniques. For example if in a file we have only one block and needed to replace line is the exactly last line. So we may use:

Seacrh for:
\[19:00\] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)

Replace with:
\[19:00\] Mo Di Mi Do Fr\r\n$1MapOut$2=901019$3\Z

or
\[19:00\] Mo Di Mi Do Fr\r\n$1MapOut$2=901019$3\r\n\Z
(if you have new line chars after last line).

Here is \Z is end of line.

Or you may "play with" number of digits in the last line of the block. Is it always the same:
In the example:
MapOut05963=90101305963
We have 5 digits after MapOut and 11 digits after =

So you may play on number of digits only:
Search for:
MapOut(\d\d\d\d\d)=901013(\d\d\d\d\d)

Replace with:
MapOut$1=901019$2\Z

You see many differents variants are possible.

[/b]
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

papamark

Wildcard

Post by papamark »

Hello Roman,
thnaks for your reply. I am getting a lot of errors if try the way you recommend.

First try:
Find
\[19:00\] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)
replace
\[19:00\] Mo Di Mi Do Fr\r\n$1MapOut$2=901081$3\Z

error message :
Error during compiling of regular expression (row number1):
" Replace with" part:invalid use of \ char at position 1
please correct syntax of this regular expression

I have changed it slightly:
Find
\[19:00] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)
replace
\[19:00] Mo Di Mi Do Fr\r\n$1MapOut$2=901081$3\Z

same error message

Next try:
[19:00\] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)
replace
[19:00\] Mo Di Mi Do Fr\r\n$1MapOut$2=901081$3\Z

Error message:
Error during compiling of regular expression (row number1):
"Serach for" part Unmatched[](pos54)
please correct....

Next try:
[19:00] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)
replace
[19:00] Mo Di Mi Do Fr\r\n$1MapOut$2=901081$3\Z

Error message:
Error during compiling of regular expression (row number1):
"ReplaceWith" invalid use of char at position 46

well, then i deleted \z, now erro but also no result, means nothing coul be found

Then I tried the other way:
\[19:00\] Mo Di Mi Do Fr\r\nMapOut02=90107002\r\nMapOut02=90107002\r\nMapOut03=90107003\r\nMapOut04=90107004\r\nMapOut05=90107005\r\nMapOut06=90107006\r\nMapOut07=90107007\r\nMapOut08=90107008\r\nMapOut09=90107009\r\nMapOut(\d+)=901013(\d+)
replace
\[19:00\] Mo Di Mi Do Fr\r\nMapOut02=90107002\r\nMapOut02=90107002\r\nMapOut03=90107003\r\nMapOut04=90107004\r\nMapOut05=90107005\r\nMapOut06=90107006\r\nMapOut07=90107007\r\nMapOut08=90107008\r\nMapOut09=90107009\r\nMapOut$1=901019$2

Error during compiling of regular expression (row number1):
" Replace with" part:invalid use of \ char at position 1
please correct syntax of this regular expression

next try
[19:00\] Mo Di Mi Do Fr\r\nMapOut02=90107002\r\nMapOut02=90107002\r\nMapOut03=90107003\r\nMapOut04=90107004\r\nMapOut05=90107005\r\nMapOut06=90107006\r\nMapOut07=90107007\r\nMapOut08=90107008\r\nMapOut09=90107009\r\nMapOut(\d+)=901013(\d+)
replace with
[19:00\] Mo Di Mi Do Fr\r\nMapOut02=90107002\r\nMapOut02=90107002\r\nMapOut03=90107003\r\nMapOut04=90107004\r\nMapOut05=90107005\r\nMapOut06=90107006\r\nMapOut07=90107007\r\nMapOut08=90107008\r\nMapOut09=90107009\r\nMapOut$1=901081$2
Error:
Error during compiling of regular expression (row number1):
"Serach for" part Unmatched[](pos241)
please correct....
If I try to find the position 241 and pasting the tex to word to count the characters I am only getting 233.
Do you have any Ideas ?

Greetings
Marks

papamark

wildcards

Post by papamark »

I have fond out that between
[19:00\] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)
[19:00\] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)

are two spaces instead of one but I still get the error message
that the "serch for part" unmatched [] at (pos 55)

I think it means the last position of the line....

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

Post by Abacre »

You forgot to place \ before [
It's for char escaping, because [ is a reserved char.

Try:
\[19:00\] Mo Di Mi Do Fr\r\n(.*)MapOut(\d+)=901013(\d+)
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

papamark

Wildcard

Post by papamark »

Hello Roman,

then it is saying:
Error during compiling of regular expression (row number1):
" Replace with" part:invalid use of \ char at position 1
please correct syntax of this regular expression

I usesed this fom you at replace:

\[19:00\] Mo Di Mi Do Fr\r\n$1MapOut$2=901019$3\r\n\Z

If I changed it by
[19:00] Mo Di Mi Do Fr\r\n$1MapOut$2=901019$3\r\n\Z
it is saying: Invalid use of \ at position 51.
Do I take \Z away, no more error message is poping up but
it also do not find a match.It looks like, that this thing is more complicated than you have guesed

Greetings, Mark

papamark

Wildcard

Post by papamark »

If I only put in
\[19:00\] Mo Di Mi Do Fr\r\n\z(.*)MapOut(\d+)=901013(\d+)

and using the just fin option wit an empty replace field it cannot find any match.

This is the original text block:

[19:00] Mo Di Mi Do Fr
MapOut02=90107002
MapOut03=90107003
MapOut04=90107004
MapOut05=90107005
MapOut06=90107006
MapOut07=90107007
MapOut08=90107008
MapOut09=90107009
MapOut02921=90101302921

papamark

wilcards

Post by papamark »

Hello Roman,

I tried out all the ways you have rcommended but at least afr is not able to handle this job. If I use both lines that you have posted I got the error message of invalid use of char \ at postion 1 and 54.
If I only use the l search side no error is comming up but it also can´t find any match.

At least you´ve tried it but it looks like that this an overload for afr.

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

Post by Abacre »

Hi,

Lets do as we normally do with our customers. We should work on
the concrete files. Please send to support@abacre.com :
* Source file you want to changed.
* Resulting file (which you changed manually).

Then I will generate you config file for AFR what does the job. You
get config file, load it into AFR and that's all.

For now it's not clear do you have trailing spaces in your file. Is
the block takes whole place in the file or not.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

papamark

wildcards

Post by papamark »

Hello Roman,

thanks for your support by EMail and sorting out this problem.
And let me apologize for critizesing the quality of your support.

It was a great help.

Thank you

Post Reply