Copy link to clipboard
Copied
Hi everyone.
I'm trying to get 'name' from 'name@domain.com' using cf reg ex.
I've got this so far #rereplace('temp.emailaddress','[^@]+','')#
which is giving me @domain.com - but I want the first part, can anyone point me in the right direction please?
Thanks ever so much.
Nick
You may treat it as a list with delimiter @:
<cfset myString = 'name@domain.com' >
<cfset namePart = listGetAt(myString,1,"@")>
Copy link to clipboard
Copied
You may treat it as a list with delimiter @:
<cfset myString = 'name@domain.com' >
<cfset namePart = listGetAt(myString,1,"@")>
Copy link to clipboard
Copied
Just thought of another one, close to yours:
rereplace('name@domain.com','@(.*)$',"",'all')
Copy link to clipboard
Copied
I used this one in the end - nice one Dan
Thank you.
Nick