ApSIC Xbench Forum

Finding word combination

Hello,

I need a regex to search for entries that contain two or more strings, but only when one word appears first as in prepositions.

So for example, I want to find the preposition “change to” in strings like “Please change the setting to Wi-Fi” but I do not want to find “To disconnect change the setting”.

Here are my settings:
Source: “change” “to”
Search mode: RegEx, whole words
Power mode: On

I tried using parenthesis (“change”) and “(change)” but I still get results where “to” appears first.

You may try the following search:

Source: "change (.* )?<to>" -"to (.* )?<change>"
Search Mode: Regular Expressions
PowerSearch, Match Whole Word: On.

Thank you @omartin but unfortunately, I get 0 results with this regex.

I have tried again with your examples and this regex works fine:

"change .* to" -"to .* change"

Search Mode: Regular Expressions
PowerSearch, Match Whole Word: On.

Thank you @omartin!

It did work, however, the regex did not catch everything. I left out the second part of the regex. This did the trick, however, I’m wondering why Xbench is not catching the first “to” in the last sentences?

These two last sentences are not detected because -"to .* change" makes that sentences that contain to before change are discarded.

Maybe this search suits your needs:

"change .* to" -"to [^,]+ change"

You may have to adapt the regex. It is a process of trial and error.

Thank you @omartin, it did work, however, it’s still weird that it detects “change the Wi-Fi connection to your preferred Wi-Fi network, then return back to” but not "“change the Wi-Fi connection to

Xbench regex is greedy (i.e. in the sense it will always try to match the longer string).

This means to make it non-greedy you need to be more specific on what you are searching for.

This search will probably do something closer to what you seem to need: change([^t])*t([^o])*o

Hi @pcondal,

What I’m searching for is the preposition “to” together with the verb “change”, but they do not always appear next to each other. The regex "change .* to" works fine for me, it only bothers me that it’s greedy (thanks for the tip :slight_smile: ).

The non-greedy regex gives me completely different results, unfortunately: