Hello,
Years ago more than 10, I used Nisus and loved the Find/Replace.
Currently I use a PC but, where I work we use both Macs and PCs. So who knows I might switch. For now I have a temp. Mac and using NW Pro Demo to work on cleaning up a data file.
Some find and replace commands work fine. The interface screen for Find is changed so I'm getting used to that.
Find and replace efforts that seem simple seem to get stuck in a loop.
Right now I'm trying Find digit,digit,"C" and replace with found (Captured1)
In my file I have e.g. "55C" at the end of each line to indicate a temperature, I'm trying to remove the "C".
The code in PowerFind not PowerFind Pro is
Capture(AnyDigit AnyDigit) C
replace with
Captured1
The file has 13.2 MB of just txt lines.
I'm probably doing something wrong/stupid. Please advise.
Thanks,
-Henry
Issue with PowerFind "Replacing Occurrances.." doesn't stop
Re: Issue with PowerFind "Replacing Occurrances.." doesn't s
Hello Henry,hccoles wrote:In my file I have e.g. "55C" at the end of each line to indicate a temperature, I'm trying to remove the "C".
When you say "end of each line", I assume you mean end of paragraph. If that's correct, then you could simply search for the last character of each paragraph, leave the "Replace with" box empty and then click on Replace All. If you enter "C" instead of AnyCharacter, then obviously only the character "C" will be found and replaced at this position. The 55C in red color will not be affected. Your solution should also work if you remember to include the "End of Paragraph" bubble, at least it worked by me without any problem.

Did you leave a space before "C"? Maybe that was the mistake.Capture(AnyDigit AnyDigit) C
replace with
Captured1
Tip:The interface screen for Find is changed
You can easily resize the search box by dragging the edges with the mouse
Re: Issue with PowerFind "Replacing Occurrances.." doesn't s
Powerfind (Pro) aka 'grep' can be a fickle thing. The other day I did a search on a file where each line had 64 or more commas. I wrote an expression to find lines with 64 commas and it selected all the lines of the file in a flash. Then I tried 65 commas, and Powerfind when into 'freeze mode'. Any humanoid can immediately tell that the second problem is a subset of the first, so it should have been quicker! That's computers for you…
-----
In principle your approach is fine, and should do what you want. But the search pattern you wrote is definitely inefficient. What it says is: "remove a C following 2 digits", but of course this will also remove a 'C' after 3, 4, 5, … digits. What's more, it will have to check every number, no matter how many digits, multiple times, until it realizes this is fruitless.
If what you really want is to remove a 'C' only after two or more digits (leaving the 'C's which follow only one digit!) then you would still be better off using the Repeat:1+ . This is because it will avoid the need to check every number multiple times.
Another approach is to use some of Þorvarður's advice. Basically you should use a position expression. Rather than using Capture use Preceded by, so:
with the replace box empty. This will remove any 'C' immediately following (at least) two digits. If the cases you are looking for are really all at the end of the paragraph, then Þorvarður's method (perhaps using a 'C' rather than 'any character') should work as well. If you are really trying to remove the 'C' only after numbers that are exactly two digits long, than you should precede the digits with a Start of word delimiter. That too would cut down on the amount of checking.
-----
In principle your approach is fine, and should do what you want. But the search pattern you wrote is definitely inefficient. What it says is: "remove a C following 2 digits", but of course this will also remove a 'C' after 3, 4, 5, … digits. What's more, it will have to check every number, no matter how many digits, multiple times, until it realizes this is fruitless.
If what you really want is to remove a 'C' only after two or more digits (leaving the 'C's which follow only one digit!) then you would still be better off using the Repeat:1+ . This is because it will avoid the need to check every number multiple times.
Another approach is to use some of Þorvarður's advice. Basically you should use a position expression. Rather than using Capture use Preceded by, so:
Code: Select all
Precededby(anyDigit anyDigit)C
philip
Re: Issue with PowerFind "Replacing Occurrances.." doesn't s
Thanks for the suggestions - I can try those and see what happens.
A test I did was to cut the file size by 1/15 and it worked.
As you all say maybe adding some efficiency will help.
I'll give those a try and report back.
A test I did was to cut the file size by 1/15 and it worked.
As you all say maybe adding some efficiency will help.
I'll give those a try and report back.
Re: Issue with PowerFind "Replacing Occurrances.." doesn't s
The PrecededBy worked very fast even on 32MB of text, using end of paragraph at the end of the find helped but didn't set any records. Thanks!