简体   繁体   中英

search using regex functionality in SQL

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%' 

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%' 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM