PDA

View Full Version : Include underscores in found strings



derbva
03-16-2022, 01:17 AM
Greetings,

I'm looking for a way to include underscores in strings I look for with Find object.
I have a data set of strings I'm looking for in a document. The strings may or may not include underscores, and the document may contain partials of that string, or more than the desired string.

Examples: I want to find following strings "Word", "Word_A", "Word_B". The document may include strings that I do not want to edit such as "Word_ABC" or "Word_A_1".
With MatchWholeWord it would find the "Word" in "Word_ABC" and "Word_A" in "Word_A_1" when those should be left unedited.

The underscores can appear anywhere within the words except for the first character, so I can't filter them based on location of the character.

gmayor
03-16-2022, 06:02 AM
For your examples, use a wildcard search for <Word_[AB]{1}>[!_]
See https://www.gmayor.com/replace_using_wildcards.htm

derbva
03-18-2022, 01:48 AM
Hi, I figure my examples were a little poorly formed.

The strings can be any set of numbers and letters with or without underscores. There also isn't any specific pattern that can be excluded (or included) by search. Words with underscore would fall under [0-9A-Z]_[0-9A-Z].
Using the filter above would obviously ignore the strings that don't have underscores. I have reviewed the data and each string I want to find and edit, can only include 0-1 underscores. The problem forms when I want to find a string of only [0-9A-Z] and the document contains same string but longer divided by an underscore (such as my previous examples).

Does this mean I should divide my data set into two parts where other has underscored strings and other doesn't? Then I could apply the underscore filter either between the [0-9A-Z]_[0-9A-Z] or to find words that do not have underscores at the end of the string.
I will have dive deeper into wildcard search to better utilize it.