1

Is there a way to termiante the wilcard in the search, when I want to search for example for two words?

Let's say I have the following words

awesome mouse
awful albatros
awesome albatros
awful mouse

Now I'm trying to find specifically the combination of

aw* alba*

so my expected matches would be awful albatros and awesome albatros as two separate results

(obviously in the example ? would be more sufficient for wildcard, but I'm trying to use the wildcard for a search in foreign language where the endings of the word can have different length depending on the noun). So please, stick with the * wildcard

I tried all sort of things, including begin of word search and nested expressions, but I keep getting false matches, because the wildcard character * keeps interpreting everything as a match afterwards and does not terminate the word.

This is the closest I could get to making sense of it -

<(aw)*{1,}\ (alba)*

Issue is, the first * accepts everything after it and eats it up, when I in fact want to terminate it after a first space and then begin searching for second word (alba*)

enter image description here

How should I go about doing this?

2 Answers 2

1

Instead of * use group, e.g.:

<aw[a-z]{1,} alba[a-z]{1,}>

  • you might need to include special characters in your group if your language contains them
  • space isn't a special character, doesn't need to be escaped
  • don't need to use brackets around strings, you might want to include the whole expression in one set of brackets (if you want to replace it for example)
  • < and > matches beginning and end of word respective.

Further reading : https://wordmvp.com/FAQs/General/UsingWildcards.htm#adv

0

Since you didn't mention whether the words appear in the same line or in new paragraph, I am assuming both situations here.

If they appear in the same line:

enter image description here

(The words appear in the same line and are separated by a space)

In order to find that particular pattern of words, press Ctrl+F to go to 'Find' menu. In "Find what:" type [space](aw)*{1,}\ (alba)* (where [space] refers to one stroke of space bar) and 'check' the 'Use Wildcards'.

Click Find next. You will have that particular pattern selected in your document:

enter image description here

(Note that this search will also select the preceding space before the two words as shown above. So if you want to replace the above text with some other text keeping the same format, do not forget to add a space before the beginning of the replacement word; e.g. Replace with: [space]SomeReplacementText)

If they appear in different paragraphs or after a carriage return (as shown):

enter image description here

In this case, in the Find what: enter this: ^13(aw)*{1,}\ (alba)* and hit 'Find Next'. This will fetch you the desired result:

enter image description here

(But remember that the above search keyword selects a preceding carriage return as shown above. So if you want to replace the above text with some other text keeping the format same do not forget to add a carriage return (^13) before the beginning of the replacement word; e.g. Replace with: ^13SomeReplacementText)

If you've those words in both the formats (i.e. in the same line as well as in new paragraphs), you've to do both steps one by one.

I hope this helps. Tell me how it does :)

2
  • [space](aw)*{1,}\ (alba)* this is essentially the same as the expression in the question May 26, 2020 at 18:17
  • Yes, perhaps. But this does the work for the problem of OP quite well and it is all that matters. There can be many ways to solve one problem, that doesn't mean one working slightly differently deserve a downvote.
    – user871532
    May 27, 2020 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .