Solved

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

Posted on 2010-11-09
11
279 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
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…

726 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