Question: regex to extract string coldfusion

Question

regex to extract string coldfusion

Answers 1
Added at 2017-09-06 19:09
Tags
Question

I have a string like below. I want to extract Fname Lname, email into two different strings using coldfusion. I've tried few things but with not much luck. Any ideas.

<cfset string = '"Fname Lname" <abc@gmail.com>' />
Answers to

regex to extract string coldfusion

nr: #1 dodano: 2017-09-06 20:09

You could try this:

<cfset string = '"Fname Lname" <abc@gmail.com>' />
<cfset tmpNameVar=mid(string,2,len(string))>
<cfset NameVar=listgetat(tmpNameVar,1,'"')>
<cfset emailVar=listgetat(tmpNameVar,2,'"')>
<cfset emailVar=replace(emailVar,"<","","ALL")>
<cfset emailVar=replace(emailVar,">","","ALL")>
<cfoutput>
name: #namevar#<BR>
email:#emailvar#
</cfoutput>

You may want to turn the process into a function.

Source Show
◀ Wstecz