?
Solved

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

Posted on 2010-11-09
11
Medium Priority
?
282 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 336 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 664 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
Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

 
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 664 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

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
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…
Suggested Courses

741 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