Have to repeat a Text Find/Replace action to get all of the instances?

Another weird one, I know. I have a pipe-delimited file that has some date fields (and several fields that are text fields). If the date field is not defined in the source of the data, the field value comes through as 0000-00-00. I created a Text Find/Replace action that is supposed to find all of the instances of |0000-00-00| and replace them with ||, writing back to the same file.

The action finds 107 matches and replaces them, but leaves several instances of the string in the file. If I run the exact same action again, it finds another 24 matches (which are all that are left) and replaces them. So, I need to put two of the same action back to back in order to get all of the matches converted.

But, in the action, I tell it to replace all of the instances that it finds in the file. Why do I need the second copy of the action to run in order to get them all? Is there a maximum number of replacements that can be made? The file has 155 rows of data, each with 17 fields - most are short text or date fields. I don’t think we are hitting a field or file size limit, but I guess I am not sure.

Running Automise 5.5.0.1673 - I know you created a newer build to handle the encryption issue I found, but I have not yet installed it.

Hi Jonathan

I will try to reproduce this today, however it would be really useful if you could send a sample file and your project (well at least the find/replace actions) to support so we have a better chance of figuring out what is going on.

The action uses regular expressions internally, so it’s rather odd that it doesn’t find them all at the same time.

How do I send just the Find/Replace actions? Though I can send the whole project file. The data file is a bit more confidential - I would have to modify it before sending it to you.

In the latest run, the first action matched 112 instances, and the second matched 25, so I don’t think we are hitting a maximum with the first action. I really do not know what is going on.

I have reproduced it here, still trying to understand why it is happening. The action uses regular expressions to do the find/replace - something is wrong with how we generate the regex.

Is your search string |0000-00-00| - try changing it to 0000-00-00 and the replacement to empty.

Do you have consecutive fields with 0000-00-00 ? If so then that is the problem, the regex matches to the ending |, the next match will start it’s search after that character.

It is entirely possible that the string |0000-00-00|0000-00-00| exists in the file. Based on what you have told me, I guess the second one would not be matched in the same action that the first one is matched in?

I changed the pattern to 0000-00-00 and replaced it with an empty string. This time the first action picked up all of the instances and replaced them. Thank you for helping me to figure that out!

Yes, the problem is that the first closing | and the second opening | are overlapping.