Remove entire line that starts with "xxx" word

19 views
Skip to first unread message

tuqqer

unread,
Dec 29, 2024, 11:33:03 AM12/29/24
to TextSoap
I have a list of 1,000 business contacts in a simple text document that needs some cleaning. I know the basics of TextSoap (owner for a dozen years), but I've never done this level of cleaning before. I'd like to know if and how to do the following: 

1. If a line starts with "Fax:", I'd like to delete the entire line (including the Return character)
2. If the line contains ".png" or ".jpg" anywhere in the line, I'd like to delete the entire line (including the Return character)
3. If a line contains "United States", I'd like to follow it with 3 (and only 3) empty Return characters. (same for "CANADA" or any other country)

Thanks for any help on this. 

Mark Munz

unread,
Jan 6, 2025, 9:23:46 AMJan 6
to text...@googlegroups.com
You'll need to create a custom cleaner

1. If a line starts with "Fax:", I'd like to delete the entire line (including the Return character)
 
image.png
This will delete any lines that start with (^) "Fax:"
.* - is a wildcard
\n - include the end of line, otherwise you'll have a blank line

2. If the line contains ".png" or ".jpg" anywhere in the line, I'd like to delete the entire line (including the Return character)
 
image.png
This one is a little more complicated. Use the If Matches Regex and make sure it matches $0
Then use the Delete Text action to delete the entire contents 

3. If a line contains "United States", I'd like to follow it with 3 (and only 3) empty Return characters. (same for "CANADA" or any other country)
 
I'm going to present two options here. If the list of countries is small, you can just use the alternating match like the one shown here:

image.png
However, if the list is larger (5-10 countries) with possibly new countries listed, then this set of actions might prove a better approach:

image.png

In Define List, I create a 1 column list (named "Country Names") and put each of the country names in
Then I use a Process List action to go through each item in a List. Select "Country Names" or whatever you chose for the name.
The last two actions (3,4) are very similar. Instead of an alternating list of country names, you use $v{A} to indicate column A of a list row.

Hope that helps.


Mark Munz
unmarked software
https://textsoap.com/

Reply all
Reply to author
Forward
0 new messages