• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Participant ,
May 26, 2014 May 26, 2014

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

TOPICS
Advanced techniques

Views

373

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 26, 2014 May 26, 2014

You may treat it as a list with delimiter @:

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

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

Votes

Translate

Translate
Community Expert ,
May 26, 2014 May 26, 2014

Copy link to clipboard

Copied

You may treat it as a list with delimiter @:

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

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 26, 2014 May 26, 2014

Copy link to clipboard

Copied

Just thought of another one, close to yours:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 29, 2014 May 29, 2014

Copy link to clipboard

Copied

LATEST

I used this one in the end - nice one Dan

Thank you.

Nick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation