Welcome to WebmasterWorld Guest from 54.160.177.33

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

RegEx help

regex

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

Junior Member

5+ Year Member

joined:July 11, 2008
posts: 88
votes: 0


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

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

Junior Member

5+ Year Member

joined:July 11, 2008
posts:88
votes: 0


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

Thanks.

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Mar 29, 2007
posts:1147
votes: 0


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';

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

Junior Member

5+ Year Member

joined:July 11, 2008
posts:88
votes: 0


...but I still need to find the string in $thePage
8:42 pm on Apr 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Mar 29, 2007
posts:1147
votes: 0


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.

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

Junior Member

5+ Year Member

joined:July 11, 2008
posts:88
votes: 0


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

Thx

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Mar 29, 2007
posts:1147
votes: 0


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.

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

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


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.

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Mar 29, 2007
posts:1147
votes: 0


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!

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

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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