Two things were the highlight of today. HTML. Argh! Trying to make something look good when you cut and paste it from a browser into outlook. It sounds easy. It's not. Our regular front end developer was out sick today, so MM and I tried as well as we could, to edit the HTML. After an hour or so, we just started the page over, and voila.. no more error!
We still don't know why it didn't work, but after wasting so much time trying to find out what was broken (basically we could see a small black line on the right of the email) we knew we could fix it just by rewriting it.
Sad.
My other highlight was a solution to a problem I'd solved in a different way. Regular expressions do my head in. I mean I can do them if I must, but usually I just find another way. A couple weeks ago I'd been asked to hyperlink an email address in a string as a mailto. I put the email in a seperate field in the database, problem solved, although not as "fancy" as i'd liked, it certainly meant for cleaner data.
My mate Brian today (Link on right to io intermedia) asked me how to pull a link out of an href without using a regular expression. I made some suggestions, but I think he already sorted it out, just needed to say it out loud (type it?). I told him about the email link thing from a couple weeks ago, and he sent me this link: http://textsnippets.com/posts/show/179.
ARGH! Lol.. it seems so simple, and I feel like a n00b. Oh well.. hopefully it helps me in the future!
Here is the code:
function extract_emails_from($string){
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
return $matches[0];
}
$text = "blah blah blah email@address.com blah blah blah email2@address.com";
$emails = extract_emails_from($text);
print(implode("\n", $emails));
BFN!
No comments:
Post a Comment