Solved

URGENT: Strip a header down

Posted on 2003-12-10
7
218 Views
Last Modified: 2006-11-17
HI All;

I have the following string:

"MyODBC List" <myodbc@lists.mysql.com>

I want to lose everything but what is inside the <>, so I need a function/regexp that takes the string above and returns:

myodbc@lists.mysql.com

Lots of points because I want to deal with this quickly.
0
Comment
Question by:Squeebee
  • 4
  • 3
7 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9918147
$text = 'MyODBC List" <myodbc@lists.mysql.com>';
preg_match_all("|<(.*)>|U",$text,$res);

print_r($res[0]);
0
 
LVL 24

Accepted Solution

by:
shivsa earned 500 total points
ID: 9918171
there is a syntex error in this.

$text = 'MyODBC List <myodbc@lists.mysql.com>';

preg_match_all("|<(.*)>|U",$text,$res);

print_r($res[0]);

0
 
LVL 17

Author Comment

by:Squeebee
ID: 9918197
Man, thank for fast response. Any way to avoid the hassle of dealing with a return in an array?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Author Comment

by:Squeebee
ID: 9918204
Oh, and the output is still wrapped in < >, I need it without any < >
0
 
LVL 17

Author Comment

by:Squeebee
ID: 9918238
Nevermind, I managed to tweak it with a str_replace!

Thanks for your help!
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9918239
could u check what
print_r($res[1]); will return i think this should return without <>.


0
 
LVL 17

Author Comment

by:Squeebee
ID: 9918246
Excellent, it does indeed.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
The viewer will learn how to count occurrences of each item in an array.

758 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

23 Experts available now in Live!

Get 1:1 Help Now