Regex help required to split a full name out of a string

In my app I have Users and Contacts stored in separate tables.
Each of these can buy something.
I’ve also made it so that random site visitors who aren’t Contacts or Users can buy things. When they do, I record their details as a kind of ‘note’ in one single field (I know it’s not best practice but it seemed “efficient”) that then contains their First Name, Last Name and Email so it’s stored, for instance, as “Joe Blogs” (but without the “” and is split by a line_break so the email appears below the name in the table). I now want to extract just the First and Last names from this string and it seems that Regex will do this…

My question is, therefore,
If I have a field called, for example, Random Person and the contents are Joe Bloggs and I now want to extract their First name and Last name so I can include them in an email that says “Joe Bloggs has bought a widget”, what should my Regex pattern look like? I have to admit that Regex is total gobbledegook to me and looks like something my cat writes when he walks on the keyboard.
I’ve tried using Regex patterns suggested in other threads in this forum but all I got was the entire string with commas instead of spaces and that’s not what I want.
I’d really appreciate any help from anyone who can understand these hyroglyphics and tell me what to type.
Many thanks

Hi there, @joefarrowsmith… have you given Bubble’s :split by operator a shot? It might get a bit tricky with the line break in there, but if you split by a space character and reference the first item, that will get you the first name, and I’m sure we could come up with a way to get the last name, too.

Anyway, I didn’t know if you had already tried that operator, so I figured I would mention it. I agree that Regex is total gobbledegook (I’m sure your cat would have a better shot at writing valid Regex than I would), and the :split by operator has helped me avoid it on plenty of occasions.

Hope this helps.


1 Like

Many thanks, as always, Mike.

I’ll certainly give the :split by operator a go and will see where that gets me. It might be that I tried it and can’t remember doing so because I’ve fumbled my way through with trial and error quite a lot recently. Maybe I should go and get the cat!

All the best

1 Like

FYI… I just made a quick example on my end… if you use the :split by operator and use a line break as the thing to split by (literally press the Enter key in the Text separator field) and then reference the first item, you should get the full name.

1 Like

Mike, Thank you so much for this. It’s working very well although can you expand on “then reference the first name”? It’s doing what I want but still has the email attached to the end which is a huge leap forward and uses a method that doesn’t involve hieroglyphics so I’m very grateful to you!

You should just need to reference the first item (not first name) by literally adding the :first item operator to the end of the expression.

1 Like

Thank you so much! I think I’m there. I read your solution incorrectly as first name, not first item - apologies for the brain fart! I just need to make an adjustment to the way my fullname field is created as I’ve just realised I did it via appending an email from an input to the contents of first and last name inputs to create a single text string so if I do that differently, I think it’s good to go.
Thank you again. You’ve moved me forwards and it’s much appreciated!

1 Like