replace [url]whatever[/url] ..
-
I have a JScript string that could potentially include text like this: [url]whatever[/url] I would like to replace it with: <a href="whatever">whatever</a> Any ideas how to do that? Thanks for any assistance!
-
I have a JScript string that could potentially include text like this: [url]whatever[/url] I would like to replace it with: <a href="whatever">whatever</a> Any ideas how to do that? Thanks for any assistance!
Have you tried working with the JScript string object[^]? If this is JScript.NET, you can just use the string class. Is this client side? Server side?
Jon Sagara "the good thing about hitting your head against a wall is when you stop" -- l a u r e n's Web page
My Articles -
Have you tried working with the JScript string object[^]? If this is JScript.NET, you can just use the string class. Is this client side? Server side?
Jon Sagara "the good thing about hitting your head against a wall is when you stop" -- l a u r e n's Web page
My ArticlesNo, it's standard JScript embedded in an ASP page (IIS5).. all server side. Basically I have a discussion forum, which doesn't allow HTML, and I would like either: (A) any links posted by the users to either appear automatically (e.g. some sort magic regular expression for "http:// + whatever + whitespace" replaces the text with a standard html link), -or- (B) as an alternative, some sort of regular expression type search for "[url] + site.com + [/url]" and replace that with a standard html type link. I found the following code on a site: http://codelib.aspemporium.com/index.aspx?pid=110&cid=3[^] Which looks to perform (A) above... however in converting the VBScript to server-side JScript I can't get the following line to work... this is my translation... strOut = re.replace( strIn, "$1" ); I assume the line about, the {1} is supposed to carry down into the $1 in this one in some fashion, but I don't quite understand how it works... and I can't seem to get it to work. Any ideas? Simply finding a URL in any particular JScript String, and replacing it with an HREF is really all I need to do. Thanks for any help!
-
No, it's standard JScript embedded in an ASP page (IIS5).. all server side. Basically I have a discussion forum, which doesn't allow HTML, and I would like either: (A) any links posted by the users to either appear automatically (e.g. some sort magic regular expression for "http:// + whatever + whitespace" replaces the text with a standard html link), -or- (B) as an alternative, some sort of regular expression type search for "[url] + site.com + [/url]" and replace that with a standard html type link. I found the following code on a site: http://codelib.aspemporium.com/index.aspx?pid=110&cid=3[^] Which looks to perform (A) above... however in converting the VBScript to server-side JScript I can't get the following line to work... this is my translation... strOut = re.replace( strIn, "$1" ); I assume the line about, the {1} is supposed to carry down into the $1 in this one in some fashion, but I don't quite understand how it works... and I can't seem to get it to work. Any ideas? Simply finding a URL in any particular JScript String, and replacing it with an HREF is really all I need to do. Thanks for any help!
I'm no JScript expert, but I know David Wulff's[^] forums do what you're looking for, and, though written in C#, so to Mike Puddephat's[^]. I think David's are even written in JScript. :)
Jon Sagara "the good thing about hitting your head against a wall is when you stop" -- l a u r e n's Web page
My Articles -
I'm no JScript expert, but I know David Wulff's[^] forums do what you're looking for, and, though written in C#, so to Mike Puddephat's[^]. I think David's are even written in JScript. :)
Jon Sagara "the good thing about hitting your head against a wall is when you stop" -- l a u r e n's Web page
My ArticlesI'm actually running David's code on one of my servers, but (unless the beta is different than the release) I think it requires something like this to create a URL: [url="http://www.forums.stardustsoftware.com"]The Stardust Software Web Site[/url] The idea of a user being able to simply type http://www.site.com and have the display code parse and provide an HREF would be cool... but my JScript RegEx skills aren't quite good enough. Regards, Larry
-
I'm actually running David's code on one of my servers, but (unless the beta is different than the release) I think it requires something like this to create a URL: [url="http://www.forums.stardustsoftware.com"]The Stardust Software Web Site[/url] The idea of a user being able to simply type http://www.site.com and have the display code parse and provide an HREF would be cool... but my JScript RegEx skills aren't quite good enough. Regards, Larry
Ah, gotcha. Larry Antram wrote: but my JScript RegEx skills aren't quite good enough. Ditto. I know that PHPBB does a good job of that, though. Don't know how well the RE will translate into JScript, though. Sorry to keep pointing you around the web... just trying to promote "code reuse." :)
Jon Sagara "the good thing about hitting your head against a wall is when you stop" -- l a u r e n's Web page
My Articles