Solved

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

Posted on 2010-11-09
11
271 Views
Last Modified: 2012-05-10
<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
Comment
Question by:myselfrandhawa
  • 6
  • 3
  • 2
11 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 84 total points
Comment Utility
Try this:
<CFSet variables.extracted =REMatch("(?<="")[^""]+(?="")" , """The randhawa"" <myselfrandhawa@yahoo.com>")>

<CFDump var= "#variables.extracted#" label ="Email Address">

Open in new window

0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
Comment Utility
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
 
LVL 35

Expert Comment

by:Terry Woods
Comment Utility
Thanks, kaufmed, for the correction! I worship your regexly knowledge! ;-)
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
I'm always disappointed whenever I find a new language/editor that doesn't fully support lookaround  :)
0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 52

Expert Comment

by:_agx_
Comment Utility
>> 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
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
@_agx_

I haven't gotten quite that far in my CF experiments yet, but true nonetheless  : )
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Since it all compiles to java anyways, why is there such a difference between the CF regex and the Java?
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Backward compatibility maybe? (CF wasn't always java based).  But that's a total guess ;-)
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
>>  ... CF wasn't always java based...

Ahh. Did not know that.
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Yeah, it's been java based for a while now. But back in dinosaur days it was written in C++ ;-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now