There is an email column in the database. I need to pull out not the full email of the user in the request, but only what is from @ to the first point. Tell me, please, how in the request to make this condition?
1 answer
Use a regular expression
select substring(email from '@(.*?)\.') from table For verification: select substring('abc.def@mail.org.ru' from '@(.*?)\.') Returns the word mail .
- If not difficult, give a link to the material that helped you deal with regular expressions. Thank! - Fitstd
- one@Fitstd Difficult. I do not remember when and where to start. In this example, in principle, the basics. when you need to peek at something that I rarely use, I look at Wikipedia ru.wikipedia.org/wiki/ ... When I was looking for the answer to your question just in Google I added 'postges string functions' and saw that substring can work with regulars. But the postgres dialect has a bit of its own, the official dock has it - Mike
- one@Fitstd postgresql.ru.net/manual/functions-matching.html - Mike
|