cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

i need a regex to get whole word with parentheses

183530
New Contributor III

SELECT '(CC) ABC' REGEXP '\\b\\(CC\\)\\b' AS TEST1,

    'A(CC) ABC' REGEXP '\\b\\(CC\\)\\b' AS TEST2,

    'A (CC)A ABC' REGEXP '\\b\\(CC\\)\\b' AS TEST3,

    'A (CC) A ABC' REGEXP '\\b\\(CC\\)\\b' AS TEST4,

    'A ABC (CC)' REGEXP '\\b\\(CC\\)\\b' AS TEST5

expected result:

TEST1 = TRUE

TEST2 = FALSE

TEST3 = FALSE

TEST4 = TRUE

TEST5 = TRUE

2 REPLIES 2

Hubert-Dudek
Esteemed Contributor III

Please share the expected output and what is condition for True and False.

183530
New Contributor III

get whole word "(CC)"

I had already written the output

expected outuput

 '(CC) ABC' REGEXP <<regex>> = TRUE

'A(CC) ABC' REGEXP <<regex>> = FALSE

'A (CC)A ABC' REGEXP <<regex>> = FALSE

 'A (CC) A ABC' REGEXP <<regex>> = TRUE

 'A ABC (CC)' REGEXP <<regex>> = TRUE

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.