Click here to Skip to main content
15,926,035 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Regular Expression messing about Pin
Andrew Peace30-Apr-02 1:38
Andrew Peace30-Apr-02 1:38 
GeneralRe: Regular Expression messing about Pin
Chris Maunder30-Apr-02 1:47
cofounderChris Maunder30-Apr-02 1:47 
GeneralRe: Regular Expression messing about Pin
Andrew Peace30-Apr-02 15:13
Andrew Peace30-Apr-02 15:13 
GeneralRe: Regular Expression messing about Pin
Jason Jystad30-Apr-02 13:11
Jason Jystad30-Apr-02 13:11 
GeneralRe: Regular Expression messing about Pin
Chris Maunder30-Apr-02 14:18
cofounderChris Maunder30-Apr-02 14:18 
GeneralRe: Regular Expression messing about Pin
Jason Jystad30-Apr-02 14:34
Jason Jystad30-Apr-02 14:34 
GeneralRe: Regular Expression messing about Pin
Jason Jystad1-May-02 9:28
Jason Jystad1-May-02 9:28 
GeneralRe: Regular Expression messing about Pin
Jack Handy2-May-02 10:12
Jack Handy2-May-02 10:12 
I messed around with it a little bit and it seems that I may have found a solution to your problem. I provided an example in perl, I don't know ASP (I came into this forum because I saw this thread discussed in the lounge).

I basically prefixed your regex with:
(^|.*?[^="'\s])\s*

It works on your example page however with a string like "test http://www.site.com test" it will match the last text before the url as well like so: "test http://www.site.com". This is why I provided the perl example below, to combat this problem. I hope this converts easily to ASP, if not let me know and I will try to think of something else.

$url = 'blah http://www.url1.com/dir/file.txt blah http://www.url2.com/dir/file.txt \'blah\'';
$url =~ s/((^|.*?[^="'\s])\s*)((http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)/$1<a href="$3" Target="_BLANK">$3<\/a>"/g;
print "[$url]\n";


It seems to work well, the only problem would be if someone quoted the word directly before the url like "so" http://www.url.com. Anyhow, I hope this helps out.

-Jack


To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
GeneralRemote database access Pin
alex.barylski29-Apr-02 14:53
alex.barylski29-Apr-02 14:53 
GeneralRe: Remote database access Pin
Philip Patrick30-Apr-02 9:54
professionalPhilip Patrick30-Apr-02 9:54 
GeneralProblem with getting a web service to work with my ASP .Net Client Pin
Ranjan Banerji29-Apr-02 8:26
Ranjan Banerji29-Apr-02 8:26 
GeneralRe: Problem with getting a web service to work with my ASP .Net Client Pin
Ranjan Banerji29-Apr-02 8:50
Ranjan Banerji29-Apr-02 8:50 
GeneralPlain Vanilla HTML Pin
Roger Wright27-Apr-02 17:11
professionalRoger Wright27-Apr-02 17:11 
GeneralRe: Plain Vanilla HTML Pin
Jon Sagara29-Apr-02 7:56
Jon Sagara29-Apr-02 7:56 
GeneralRe: Plain Vanilla HTML Pin
Roger Wright29-Apr-02 13:50
professionalRoger Wright29-Apr-02 13:50 
GeneralRe: Plain Vanilla HTML Pin
Jon Sagara29-Apr-02 20:56
Jon Sagara29-Apr-02 20:56 
GeneralRe: Plain Vanilla HTML Pin
Roger Wright30-Apr-02 2:40
professionalRoger Wright30-Apr-02 2:40 
GeneralRe: Plain Vanilla HTML Pin
Chris Maunder30-Apr-02 2:12
cofounderChris Maunder30-Apr-02 2:12 
GeneralRe: Plain Vanilla HTML Pin
Roger Wright30-Apr-02 2:41
professionalRoger Wright30-Apr-02 2:41 
Questionphp or asp? Pin
27-Apr-02 14:16
suss27-Apr-02 14:16 
AnswerRe: php or asp? Pin
Fernando Finelli28-Apr-02 3:57
Fernando Finelli28-Apr-02 3:57 
GeneralRe: php or asp? Pin
l a u r e n28-Apr-02 4:58
l a u r e n28-Apr-02 4:58 
GeneralRe: php or asp? Pin
Ravi Bhavnani28-Apr-02 7:31
professionalRavi Bhavnani28-Apr-02 7:31 
GeneralRe: php or asp? Pin
Fernando Finelli29-Apr-02 4:38
Fernando Finelli29-Apr-02 4:38 
GeneralRe: php or asp? Pin
Nish Nishant29-Apr-02 14:53
sitebuilderNish Nishant29-Apr-02 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.