Welcome to WebmasterWorld Guest from 54.226.194.180

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

RegEx help

regex

     

iamvela

10:21 am on Apr 24, 2009 (gmt 0)

5+ Year Member



Hi:

I need some help with writing a regex that will take ANY generic mailto link such as
mailto:#*$!?subject=yyy etc.

and convert it into the same with an additional param added such as
mailto:#*$!?subject=yyy&myparam=myval

I'd appreciate any help. Thanks,
--

iamvela

10:27 am on Apr 24, 2009 (gmt 0)

5+ Year Member



BTW I will need to search for the mailto link in the first place (in my PHP variable lets call it $thePage).

Thanks.

Dabrowski

1:38 pm on Apr 24, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Unless I'm completely missing the point here, you don't need a regex at all. A simple string cat will do?

$myLink = 'mailto:#*$!?subject=yyy';
$myLink .= '&myparam=myval';

iamvela

5:26 pm on Apr 24, 2009 (gmt 0)

5+ Year Member



...but I still need to find the string in $thePage

Dabrowski

8:42 pm on Apr 24, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I see. This regex will store the contents of the href property in $1:

href=['"](.*?)['"]

As you may see it will work with single or double quotes.

iamvela

8:47 pm on Apr 24, 2009 (gmt 0)

5+ Year Member



Aaah thanks but we still need to put in the mailto itself, not just any http: https etc. :)

Thx

Dabrowski

11:40 am on Apr 28, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I'm not sure what you mean? Your original post implies that you already have a mailto link?

ok, why don't you give me an example of the exact string you want to work on.

rocknbil

4:26 pm on Apr 29, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Kudos to D. for patience and persistence, I'd like to add it would be so much easier to provide a solution if you would just let us know the complete task behind your questions, from environment to input to output.

Where are these mailto's coming from? Static pages, other sites? Your output? A message board?

What is the real task you hope to achieve? Adding a new parameter to all mailto's?

There is one *huge* issue here that may make all this just not worth your time. Mailto links work only if the user has, and uses, a default mail program on their computer. The browser "queries" the system for the default mail program, opens it, and opens a new email populating the to, subject, and even body fields.

What if I use Yahoo Mail,Gmail, msn, AOL web mail, and have never launched Outlook, as an increasing number of users do?

The system does the same thing, most likely opening Outlook Express, and the reaction by the user ranges from confusion to horror (OMG, it's a pop up, it's a virus, what is this, I've never seen this . . . )

See where that goes?

So tell us what your actual task is, we could offer a *real* solution.

One example: find those mailto:links and substitute out the whole wad to point to a contact form that will work for everyone.

Dabrowski

9:33 am on Apr 30, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



What if I use Yahoo Mail,Gmail, msn, AOL web mail, and have never launched Outlook

You know, that's a really good point. I'd never have thought of that!

g1smd

10:23 pm on Apr 30, 2009 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Not only that, if you are adding a custom parameter, the target program is likely simply going to ignore it.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month