Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Regex of URL's
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

JJenson
Advanced Member

USA
2121 Posts

Posted - 26 August 2007 :  12:41:43  Show Profile  Visit JJenson's Homepage
I am trying to figure out how to convert automatically using regext a url that looks like this.

www.vmcplugins.com

into something that will display on an page as a link. I cannot figure out how I would write this to have it parse out correctly. THis is how I am using regex with other fields.

PreSubmit2 = REPLACE(PreSubmit2,vbcrlf,"<br>") 'Put Spaces into post.

THanks I just can't get it to work for me Big surprise huh? lol

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 26 August 2007 :  12:59:43  Show Profile  Visit HuwR's Homepage
download the .Net version and have a look in the formatting.cs file, one of the rgex's in the replaceurls function will do what you need, it is very similar in asp to .net so should be easy to convert it.

by the way
PreSubmit2 = REPLACE(PreSubmit2,vbcrlf,"<br>") 'Put Spaces into post.
is not a regexp, it is just a standard text replace

Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 26 August 2007 :  13:03:07  Show Profile  Visit JJenson's Homepage
lol oh

Well I will have a look cause I need to have some regex for formating url's

Thanks HuwR

Sometimes I am not so good with calling things how they should be but learning.
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 26 August 2007 :  13:14:28  Show Profile  Visit JJenson's Homepage
IS this the line of code you were talking about HuwR?


fString = Regex.Replace(fString, matchstring, "<a href='${url}'>${url}</a> ", RegexOptions.Multiline | RegexOptions.IgnoreCase);
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 26 August 2007 :  14:14:28  Show Profile  Visit HuwR's Homepage
there several , would probably try this one
matchstring = @"((((?<!]|\x22)https?)://)([\d\w\-]+\.)?([\w\d\-\.]+\.[\w\d]+)((/ [\w\d\.\-@%\\\/:(),]*)+(\? [\w\d\?%,\.\/\#!@:=\+~_\-&]*)?)?(?<![\.]))";
fString = Regex.Replace(fString, matchstring, "<a href='$1'>$4$5</a>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

depends what exactly you want to do with it.
Check out this site http://www.radsoftware.com.au/ they have some good stuff about regexp's and a tool you can download to test with.
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 26 August 2007 :  14:23:05  Show Profile  Visit JJenson's Homepage
Basically what I want to do is what this site does when someone enters a url then once posted it turns into a clickable link.
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 26 August 2007 :  16:14:27  Show Profile  Visit JJenson's Homepage
Hey Huw I have been trying to get that line to work and I have no idea on how to that that included into this function. I have taken it out and this is what I am starting with:


FUNCTION PreSubmit2(p_sTargetString)
PreSubmit2 = REPLACE(p_sTargetString,"textarea","")
PreSubmit2 = replace(PreSubmit2, "<b>", "<b>") 'replace <b> open
PreSubmit2 = replace(PreSubmit2, "</b>", "</b>") 'replace </b> close
PreSubmit2 = replace(PreSubmit2, "<u>", "<u>") 'replace <u> open
PreSubmit2 = replace(PreSubmit2, "</u>", "</u>") 'replace </u> close
PreSubmit2 = replace(PreSubmit2, "<i>", "<i>") 'replace <i> open
PreSubmit2 = replace(PreSubmit2, "</i>", "</i>") 'replace </i> close
PreSubmit2 = replace(PreSubmit2, ""]", """>") 'replace url end enclosure
PreSubmit2 = replace(PreSubmit2, "<font", "<font ") 'replace font tag and comment out
PreSubmit2 = replace(PreSubmit2, "</font", "</font>< ") 'replace font tag and comment out
PreSubmit2 = replace(PreSubmit2, "">", " "">") 'replace font tag and comment out
PreSubmit2 = replace(PreSubmit2, "<ul>", "<ul>") 'replace font tag and comment out
PreSubmit2 = replace(PreSubmit2, "</ul>", "</ul>") 'replace font tag and comment out
PreSubmit2 = replace(PreSubmit2, "<li>", "<li>") 'replace font tag and comment out
PreSubmit2 = replace(PreSubmit2, "</li>", "</li>") 'replace font tag and comment out
PreSubmit2 = REPLACE(PreSubmit2,vbcrlf,"<br>") 'Put breaks into the post
PreSubmit2 = Trim(PreSubmit2)
END FUNCTION


Can you give me a little more guidance on how I would go about implementing the sbove line into this funtion?

THanks

Edited by - JJenson on 26 August 2007 16:17:28
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07