Regex, Truncate to... or something else

I want to extract the part of my user’s email that comes before @ and use that as their user name. so if email is “abc@gmail.com” or “abc@xyz.net” the username would be “abc”. Whats the best way to do this I tried regex “^abc$” but does not work

1 Like

Hi there, @yamirb… you can use Bubble’s :extract operator to extract the alias (you can literally select Alias as one of the options) from an email address, so give that a shot because it should do the trick for you.

Hope this helps.

Best…
Mike

1 Like

If @mikeloc 's solution doesn’t work,
Use this Regex
[^@]+ : first item

Maybe try :split by(@):first item which basically makes a list of texts from a value of type text (in this case, an email address) using the “@” symbol as the delimiter and then returns the first item in that list, which would be everything before the “@”. Regex shouldn’t be needed.

-Steve

1 Like

Neither should :split by, seeing as how :extract literally has an option for alias. :slight_smile:

As with all things Bubble, though, there are plenty of ways to do something, and this one is no exception. So, @yamirb, pick the one you like and run with it.

1 Like

I just learned something. I’ve never referred to the username portion of an email as the “alias”. I was unaware of that option! :neutral_face: Thanks, @mikeloc.

Indeed, nearly always more than one means to the same end with Bubble! :+1:

-Steve

1 Like

@mikeloc :extract worked exactly as I wanted. Very elegant. Thank you very much.

1 Like

This was exactly my question, and both solutions worked (split worked for space dividers too).