0 votes

Dave, building on your earlier explanation of how to use this regular expression to find target words in their original (and unique) context:


I'd like to run a similar search that finds contextual occurrences of the phrase -- he was ing -- where the is a wildcard intended to allow any number or type of characters within the word ending in ing.

Such a search might return the results:

of course he was hitting it too hard at the moment
even if he was eating it correctly, he
it seemed he was tiring of the event already

I tried to use this regular expression search, but it failed to identify and return any results:

.{0,20}he was *ing.{0,20}

Can you advise me whether this is possible?

Many, many thanks!


ps: since originally posting this question, I've discovered that "he was *ing" doesn't even work as a simple Boolean search expression, so clearly I'm missing something here!

by (245 points)

1 Answer

0 votes

Yes, but since you're using regular expressions you need to modify what you think of as a wildcard character. Instead of * use .* for example:

.{0,20}he was .*ing.{0,20}

The . matches ANY character and the * specifies the number of repeats as zero to many. However since . matches any character it'll also match space so instead use the word character class represented by \w, e.g.

.{0,20}he was \w*ing.{0,20}

Why wasn't the Boolean expression working?

You can't use Boolean wildcards within quotes. As soon as the Boolean expression parser finds a section of text in quotes it treats it as literal text. This is important when searching for sections for code, e.g.

"int x = (a * b)"

Without the quotes the parenthesis and asterisk would be treated as Boolean expression instructions.

by (28.0k points)
Can you enlighten me?  Is there a Boolean search that is functionally equivalent to the following Regular Expression search:

he was \w*ing

Probably not, but I thought I'd ask, just to be sure.
No, I'm afraid there's not a Boolean equivalent. I'll add your request to the Issue Tracker for future consideration.
Hi Dave,

I was just curious to know if there are multiple ways to achieve the same results. From my perspective, it's not necessary to submit a request on my behalf to the Issue Tracker.

Thanks, Dave, for all you wonderful support -- your support transforms the practical value of the software, and is in every sense, a form of pre-sales as I will now definitely be upgrading to FileLocator Pro 8.