• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Need a Bit more change in the extraction of name from email address

<CFSet variables.extracted =REMatch("""[^""]+""" , """The randhawa"" <myselfrandhawa@yahoo.com>")>
<CFDump var= "#variables.extracted#" label ="Email Address">


Currently it is showing as:

"The randhawa"

i want it to be as:

The randhawa

removing the quotes, please guide
0
Gurpreet Singh Randhawa
Asked:
Gurpreet Singh Randhawa
  • 6
  • 3
  • 2
3 Solutions
 
Terry WoodsIT GuruCommented:
Try this:
<CFSet variables.extracted =REMatch("(?<="")[^""]+(?="")" , """The randhawa"" <myselfrandhawa@yahoo.com>")>
<CFDump var= "#variables.extracted#" label ="Email Address">

Open in new window

0
 
käµfm³d 👽Commented:
Lookbehind is not supported in CF.

You may get by with the following, but it will fail if you have any text with a quote before it. For example, the following:

    "This is awesome!!"; "The randhawa" <myselfrandhawa@yahoo.com>

would return

    This is awesome!!
<CFSet variables.extracted=REMatch("[^""]+(?="")", """The randhawa"" <myselfrandhawa@yahoo.com>") />
<CFDump var=#variables.extracted# label="Email Address" />

Open in new window

0
 
Terry WoodsIT GuruCommented:
Thanks, kaufmed, for the correction! I worship your regexly knowledge! ;-)
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
käµfm³d 👽Commented:
I'm always disappointed whenever I find a new language/editor that doesn't fully support lookaround  :)
0
 
käµfm³d 👽Commented:
Maybe two regex operations would be better:
<CFSet variables.extracted=REMatch("""[^""]+", """The randhawa"" <myselfrandhawa@yahoo.com>") />
<CFSet variables.extracted=REReplace(variables.extracted[1],"""","") />
<CFDump var=#variables.extracted# label="Email Address" />

Open in new window

0
 
_agx_Commented:
>> I'm always disappointed whenever I find a new language/editor that doesn't
>> fully support lookaround  :)

Yeah,  that's one failing in the basic regex functionality. But you could easily use the underlying java, which IIRC does support it ;-)
0
 
käµfm³d 👽Commented:
@_agx_

I haven't gotten quite that far in my CF experiments yet, but true nonetheless  : )
0
 
käµfm³d 👽Commented:
Since it all compiles to java anyways, why is there such a difference between the CF regex and the Java?
0
 
_agx_Commented:
Backward compatibility maybe? (CF wasn't always java based).  But that's a total guess ;-)
0
 
käµfm³d 👽Commented:
>>  ... CF wasn't always java based...

Ahh. Did not know that.
0
 
_agx_Commented:
Yeah, it's been java based for a while now. But back in dinosaur days it was written in C++ ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now