Skip to main content
Inspiring
May 26, 2014
Answered

How to get 'name' from 'name@domain.com' using cf reg ex?

  • May 26, 2014
  • 3 replies
  • 502 views

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 @7431982.com - but I want the first part, can anyone point me in the right direction please?

Thanks ever so much.

Nick

This topic has been closed for replies.
Correct answer BKBK

You may treat it as a list with delimiter @:

<cfset myString = 'name@domain.com' >

<cfset namePart = listGetAt(myString,1,"@")>

3 replies

Nick WayAuthor
Inspiring
May 29, 2014

I used this one in the end - nice one Dan

Thank you.

Nick

BKBK
Community Expert
Community Expert
May 26, 2014

Just thought of another one, close to yours:

rereplace('name@domain.com','@(.*)$',"",'all')

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
May 26, 2014

You may treat it as a list with delimiter @:

<cfset myString = 'name@domain.com' >

<cfset namePart = listGetAt(myString,1,"@")>