0

let's say I have a string like Michael is studying at the Faculty of Economics at the University

and I need to check if a given string contains the following expression: Facul* of Econom*

where the star sign implies that the word can have many different endings

In general, my goal is to find similar expressions within tables from the clickhouse database. If you suggest other options for solving this problem, I will be grateful

2 Answers 2

1

If you want to match any lowercase letters following your two words use this:

\bFacul[a-z]* of Econom[a-z]*\b

If you want to match any optional letters following your two words use this:

\bFacul[A-Za-z]* of Econom[A-Za-z]*\b

Explanation:

  • \b - word boundary
  • Facul - literal text
  • [A-Za-z]* - 0 to multiple alpha chars
  • of - literal text
  • Econom - literal text
  • [A-Za-z]* - 0 to multiple alpha chars
  • \b - word boundary

If you want to be be more forgiving with upper/lowercase and spaces use this:

\b[Ff]acul[A-Za-z]* +of +[Ee]conom[A-Za-z]*\b
1

Use any number of "word" chars for word tails and "word boundary" at the front:

\bFacul\w* of Econom\w*

consider case insensitivity too:

(?i)\bfacul\w* of econom\w*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.