0

I am trying to pull off the first part of an email before the @ symbol.

This works:

SELECT substring(email, '(\S+)(@{1})')

However I'd like to also only pull off the first 15 (or less) characters.

How can I do this?

SELECT substring(email, '(\S+)(@{1})', 15)

doesn't work.

Thanks!

2
  • LEFT(substring(email,'(\S+)(@{1})'), 15)? Commented Aug 24, 2018 at 14:11
  • Can you please provide an example? Commented Aug 24, 2018 at 14:19

1 Answer 1

4

How about:

select left(substring(email, '^[^@]*'), 15)

Or, if you want one regular expression:

select substring(email, '^[^@]{1,15}')
Sign up to request clarification or add additional context in comments.

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.