Using Wildcards?

252 views
Skip to first unread message

rocky...@gmail.com

unread,
Aug 18, 2013, 12:30:41 PM8/18/13
to text...@googlegroups.com
I am trying to find and delete text that contains much of the exact text string, but also contains some different numbers.

For example, I want to search for and remove the following:
[caption id="attachment_3777" align="aligncenter" width="990"]
[caption id="attachment_5457" align="aligncenter" width="990"]
[caption id="attachment_3492" align="aligncenter" width="990"]
[caption id="attachment_9267" align="aligncenter" width="990"]
[caption id="attachment_2398" align="aligncenter" width="990"]

I want to remove all of this text. Most of it is the same, other than the attachment numbers. 

So, I want to somehow search for:
[caption id="attachment_****" align="aligncenter" width="990"], where the "*" is a wildcard.

Thanks for your help!

Mark Munz

unread,
Aug 18, 2013, 7:34:20 PM8/18/13
to text...@googlegroups.com
Regular Expressions (regex) allows for a variety of "wildcards.

. (dot) is used to specify any character.

You can insert the appropriate character(s) for regex using the T menu in any find field.

Regex also lets you specify specific type of characters, so you can use \d+ to represent 1 or more digits.
You didn't give any details with what you were trying to do with this match, so I'm limited in the advice I can offer.



--
You received this message because you are subscribed to the Google Groups "TextSoap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to textsoap+u...@googlegroups.com.
To post to this group, send email to text...@googlegroups.com.
Visit this group at http://groups.google.com/group/textsoap.
For more options, visit https://groups.google.com/groups/opt_out.



--
Mark Munz
unmarked software
http://www.unmarked.com/

rocky...@gmail.com

unread,
May 12, 2014, 3:02:20 PM5/12/14
to text...@googlegroups.com, unma...@gmail.com
I wanted to completely remove/delete (or replace with nothing) the following lines:


[caption id="attachment_3777" align="aligncenter" width="990"]
[caption id="attachment_5457" align="aligncenter" width="990"]
[caption id="attachment_3492" align="aligncenter" width="990"]
[caption id="attachment_9267" align="aligncenter" width="990"]
[caption id="attachment_2398" align="aligncenter" width="990"]

Since the 4 numbers of the attachment ID are variable, I cannot seem to figure out how to create an action that will remove text with variables.

apkawel

unread,
May 25, 2014, 9:05:10 AM5/25/14
to text...@googlegroups.com, unma...@gmail.com, rocky...@gmail.com
1. Set up a new custom cleaner.

2. Give it a name.

3. Add "Regex Find and Replace Text" cleaner.

4. In the top line, add the following:

\[caption id="attachment_\d+" align="aligncenter" width="\d+"]

That regex will match the general pattern of your lines. The \d+ means that it will match one or more digits in that spot (so, it would match "attachment_1" and "attachment_9485293948572394857234982734"; likewise, it would match width="3" and width="3842934892374").

5. Leave the bottom line of the "Regex Find and Replace Text" cleaner blank: this replaces the matched text of the top line with nothing (effectively deleting it).

6. If you wish, add the "Strip 2 or More Returns" cleaner. (The regex cleaner above still leaves blank lines behind; this will delete them too.)

7. Save the custom cleaner.

8. Run custom cleaner on your files.

9. Rejoice.

10. Remember that you can perform "Batch File Cleaning" on several files at once.

11. Remember that you can automate cleaning with Automator, Hazel, Keyboard Maestro, etc. For example, you could set up an Automator action or Applescript and have Hazel run it on all files added to a particular folder.

Hope this helps!

Cheers,

Andy
Reply all
Reply to author
Forward
0 new messages