Solved

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

Posted on 2010-11-09
11
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 84 total points
ID: 34096935
Try this:
<CFSet variables.extracted =REMatch("(?<="")[^""]+(?="")" , """The randhawa"" <myselfrandhawa@yahoo.com>")>
<CFDump var= "#variables.extracted#" label ="Email Address">

Open in new window

0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
ID: 34097511
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
ID: 34097537
Thanks, kaufmed, for the correction! I worship your regexly knowledge! ;-)
0
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 
LVL 75

Expert Comment

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

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
ID: 34097617
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
 
LVL 52

Expert Comment

by:_agx_
ID: 34097806
>> 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 75

Expert Comment

by:käµfm³d 👽
ID: 34097826
@_agx_

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

Expert Comment

by:käµfm³d 👽
ID: 34097833
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_
ID: 34097850
Backward compatibility maybe? (CF wasn't always java based).  But that's a total guess ;-)
0
 
LVL 75

Expert Comment

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

Ahh. Did not know that.
0
 
LVL 52

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
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…

691 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