Solved Highlight text next to dashes in MS Word (using Find)

Whitebox / MINE
June 12, 2019 at 05:18:28
Specs: Windows 7, e6850/4GB
Is there a way to use FIND to highlight all text that has a dash (hyphen) to the left or right of it?

Example of things I need to highlight:

2-11-3
4-7-1
19-20-4, 6-1-1
7-4-2

I don't know if there is a wildcard formula that lets me highlight all occurances of these. Maybe something that follows the logic of "Highlight all to the left or right of a hyphen" or something like that?


See More: Highlight text next to dashes in MS Word (using Find)

Report •

✔ Best Answer
June 12, 2019 at 19:18:02
OK, it took a bit of fiddling with the numbers,
but this seems to give you what your looking for:

<[0-9]{1,99}-[0-9]{1,99}-[0-9]{1,99}

See how it works for you.

MIKE

http://www.skeptic.com/



#1
June 12, 2019 at 07:45:36
Try this:

Open your Word doc,
On the ribbon select Home Tab
Select Find
In the Find Box, on the lower left, select More
Check the box next to Use Wildcards
In the Find What box at the top enter any one of the following three:

Character to the Left of a Dash: ?-

Character to the Right of a Dash: -?

Character to the both the Left & Right of a Dash: ?-?

The question mark is a wild card that matches any Single Character.

MIKE

http://www.skeptic.com/

message edited by mmcconaghy


Report •

#2
June 12, 2019 at 08:05:16
Just in case you need it, the wild card for multiple characters is the star *

In your example you have sets of three characters
separated by two dashes
so something like: *-*-* should work to highlight each group.

MIKE

http://www.skeptic.com/

message edited by mmcconaghy


Report •

#3
June 12, 2019 at 12:42:21
"*-*-* should work "

Close, but I'm afraid it didn't get the whole string:

https://i.imgur.com/f48Oe4f.jpg


"Character to the both the Left & Right of a Dash: ?-?"

I tried this, but I'm afraid it's only limited to one character.

https://i.imgur.com/fjEdD9N.jpg


We're getting close, though. Any help appreciated.


Report •

Related Solutions

#4
June 12, 2019 at 13:08:53
I don't think you should expect the Find function to
highlight the entire string of characters. It should be
enough that it finds all of the strings for you and doesn't
miss any. You then will have to select the part of each
string that you want.

The more variety there is in how the characters can be
strung together, the more rules are needed to select
exactly what you want. When I've done searches like
this, I have generally made several passes, one pass
for each rule. Maybe I could have combined some of
the rules together to make fewer passes.

-- Jeff, in Minneapolis


Report •

#5
June 12, 2019 at 14:04:32
What is it your actually trying to do?
There may be other way to accomplish what your really trying to do.

I don't think there is an easy way to select all the strings you want, because in addition to the dash's and numbers you have a comma, as well as line break characters and/or paragraph marks that need to be accounted for.
The hard part of using Wild Cards is telling it when to Stop searching.

None of the several ways I have tried works consistently over the whole document.

This finds the beginng & end of the "word", ie your string of characters: <*-*-*>

This one adds a Line break character to the end: <*-*-*>^|

This one a paragraph mark: <*-*-*>^p

But none of these account for the string separated by the comma.

As Jeff Root pointed out:
The more variety there is in how the characters can be
strung together, the more rules are needed to select

Here are a couple of sites on how to use Wild Cards:

https://www.officetooltips.com/word...

http://wordfaqs.ssbarnhill.com/Nonp...

MIKE

http://www.skeptic.com/

message edited by mmcconaghy


Report •

#6
June 12, 2019 at 14:16:52
Here is another one that almost works, but misses the one before the comma:

<[1-9]{1,2}-[1-9]{1,2}-[1-9]{1,2}>

MIKE

http://www.skeptic.com/


Report •

#7
June 12, 2019 at 19:18:02
✔ Best Answer
OK, it took a bit of fiddling with the numbers,
but this seems to give you what your looking for:

<[0-9]{1,99}-[0-9]{1,99}-[0-9]{1,99}

See how it works for you.

MIKE

http://www.skeptic.com/


Report •

#8
June 13, 2019 at 12:47:59
<[0-9]{1,99}-[0-9]{1,99}-[0-9]{1,99}

It works!

Thankyou so much, mmcconaghy. This is the perfect, quick n' elegant solution I needed that makes my job lightning faster. Thankyou so very much!


Report •

Ask Question