homepage Welcome to WebmasterWorld Guest from 54.166.14.218
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
RegEx help
regex
iamvela

5+ Year Member



 
Msg#: 3899419 posted 10:21 am on Apr 24, 2009 (gmt 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,
--

 

iamvela

5+ Year Member



 
Msg#: 3899419 posted 10:27 am on Apr 24, 2009 (gmt 0)

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

Thanks.

Dabrowski

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3899419 posted 1:38 pm on Apr 24, 2009 (gmt 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';

iamvela

5+ Year Member



 
Msg#: 3899419 posted 5:26 pm on Apr 24, 2009 (gmt 0)

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

Dabrowski

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3899419 posted 8:42 pm on Apr 24, 2009 (gmt 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.

iamvela

5+ Year Member



 
Msg#: 3899419 posted 8:47 pm on Apr 24, 2009 (gmt 0)

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

Thx

Dabrowski

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3899419 posted 11:40 am on Apr 28, 2009 (gmt 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.

rocknbil

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



 
Msg#: 3899419 posted 4:26 pm on Apr 29, 2009 (gmt 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.

Dabrowski

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3899419 posted 9:33 am on Apr 30, 2009 (gmt 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!

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3899419 posted 10:23 pm on Apr 30, 2009 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved