AK
12-10-2000, 06:42 PM
This shouldn't be too hard, but I think I would save a lot of time if I got some help from you guys, rather than try to do it on my own. In my forum, I have this line:
$body =~ s/http:\/\/(\S+)/<a target="NewWindow" href="http:\/\/$1">$1<\/a>/gi;
It looks for the presence of "http://" in the body text of a message, and turns the text following it (until the first space)into a hyperlink.
I would like to check the variable $1 (that contains the text that is turned into a link) so that it can not end with anything but letters, numbers or "/". If it does, the </a> tag should be inserted just before the last, invalid, character.
The reason is, of course, that a lot of people enter an URL at the end of a sentence (followed by a period), between quotation marks or in paranthesis (sp?), which corrupts the link.
Can this be easily achieved?
Oh, and while I'm at it... It would be very good if I could check the length of the URL. Only the first 50 characters should be shown on the screen, followed by "..." if the string is longer than that. Long URLs have a tendency to mess up my tables.
[This message has been edited by AK (edited 12-10-2000).]
$body =~ s/http:\/\/(\S+)/<a target="NewWindow" href="http:\/\/$1">$1<\/a>/gi;
It looks for the presence of "http://" in the body text of a message, and turns the text following it (until the first space)into a hyperlink.
I would like to check the variable $1 (that contains the text that is turned into a link) so that it can not end with anything but letters, numbers or "/". If it does, the </a> tag should be inserted just before the last, invalid, character.
The reason is, of course, that a lot of people enter an URL at the end of a sentence (followed by a period), between quotation marks or in paranthesis (sp?), which corrupts the link.
Can this be easily achieved?
Oh, and while I'm at it... It would be very good if I could check the length of the URL. Only the first 50 characters should be shown on the screen, followed by "..." if the string is longer than that. Long URLs have a tendency to mess up my tables.
[This message has been edited by AK (edited 12-10-2000).]