Skip to content
Advertisement

Wildcard for string before @ character

How would I use a wildcard to filter out any permutation of the following. There can be any number of zeros before the “@” character. Example

   0@test.com
   000000@test.com
   00000000000@test.com

Basically, I’m looking to wildcard any email address with only zeros before the @ character.

Any help would be greatly appreciated Thank you !

Smiddy

Advertisement

Answer

T-SQL:

To remove all values with only zeros before the @

SELECT 
    * 
FROM (SELECT  '000@test.com' AS[values]  ) [table]
WHERE
    LEN(REPLACE((LEFT([values],CHARINDEX('@',[Values])-1)),'0',''))  <> 0

— LEFT & CHARINDEX : get the result LEFT of the @
— LEN & REPLACE : After all 0 are replaced by ” any email that contained only zeros will result in len = 0.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement