Welcome to Geeklog, Anonymous Sunday, May 19 2024 @ 07:02 am EDT
Geeklog Forums
Please help with URL rewriting + RegEx
Rusty
Anonymous
I have been cracking my head open over the following regular expression... it works partly but in other ways it really bugs me...
here is the code:
$str = ereg_replace( \"^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*.[a-z]{1,3}$\", \"<a href=\"mailto:\0\">\0</a>\", $str );
$str = ereg_replace(\"(([^.<>[:space:]]+.)|([[:alpha:]]+://))+\". \"[^.<>[:space:]]+.[^<>[:space:]]+\", \"<a href=\"http://\0\" target=\"_blank\" title=\"\0\">Link to website</a>\", $str);
$str = ereg_replace(\"http://([[:alpha:]]+://)\",\"\1\",$str);
The urls are replaced correctly,but the emails are not...and the emails are formatted as if they were links and not as emails...as intended...
Any help VERY APPRETIATED
Text Formatted Code
$str = ereg_replace( \"^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*.[a-z]{1,3}$\", \"<a href=\"mailto:\0\">\0</a>\", $str );
$str = ereg_replace(\"(([^.<>[:space:]]+.)|([[:alpha:]]+://))+\". \"[^.<>[:space:]]+.[^<>[:space:]]+\", \"<a href=\"http://\0\" target=\"_blank\" title=\"\0\">Link to website</a>\", $str);
$str = ereg_replace(\"http://([[:alpha:]]+://)\",\"\1\",$str);
4
10
Quote
Rusty
Anonymous
Okay i fixed the email reg ex... thanks...
Would anyone have any suggestions as to how can i take out my links...and if too long make them shorter with a ... kinda thing...
once i get the string i can easily use strlen
2
8
Quote
All times are EDT. The time is now 07:02 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content