Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. replace [url]whatever[/url] ..

replace [url]whatever[/url] ..

Scheduled Pinned Locked Moved Web Development
tutorialquestion
6 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larry Antram
    wrote on last edited by
    #1

    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!

    J 1 Reply Last reply
    0
    • L Larry Antram

      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!

      J Offline
      J Offline
      Jon Sagara
      wrote on last edited by
      #2

      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

      L 1 Reply Last reply
      0
      • J Jon Sagara

        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

        L Offline
        L Offline
        Larry Antram
        wrote on last edited by
        #3

        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!

        J 1 Reply Last reply
        0
        • L Larry Antram

          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!

          J Offline
          J Offline
          Jon Sagara
          wrote on last edited by
          #4

          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

          L 1 Reply Last reply
          0
          • J Jon Sagara

            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

            L Offline
            L Offline
            Larry Antram
            wrote on last edited by
            #5

            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

            J 1 Reply Last reply
            0
            • L Larry Antram

              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

              J Offline
              J Offline
              Jon Sagara
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups