0

I am searching for a keyword using SQL server and Regex Functionality.

we have a data like leaky gas, leaked gas, and leaking gas.

SELECT [Text field]
FROM [Global database] 
text field is like '%leak[a-z]{1,3} gas%' 
3
  • Could this help you ? Select [Text field] from [Global database] text field is like '%leak%gas%' Commented Mar 2, 2018 at 23:56
  • I don't want text search where like "the leak is not from gas." Commented Mar 3, 2018 at 0:04
  • WHERE Clause is missing.. Commented Mar 3, 2018 at 3:07

2 Answers 2

1

SQL Server does not support regular expressions (unless you add your own UDF). It does however extend the LIKE functionality for some basic wildcards.

You can do what you want as:

where field like '%leak[a-z] gas%' or
      field like '%leak[a-z][a-z] gas%' or
      field like '%leak[a-z][a-z][a-z] gas%' 
Sign up to request clarification or add additional context in comments.

Comments

0

You can create a regex CLR that can be used in SQL.

https://www.red-gate.com/simple-talk/sql/t-sql-programming/clr-assembly-regex-functions-for-sql-server-by-example/

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.