472,358 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

String Manipulation

I have a text string which comes from a form containing the article text in
a knowledgebase. Sometimes people enter http links in their text however
when they show on the webpage they do not show as hyperlinks, because
obviously they don't gave the link tags around them.

What I'd like is to manipulate this text string so that wherever there is
http in it it put's the link tags around it. So what I'm really asking is,
how can I convert this string:

And to get to the blah blah site please go to http://blah-blah.com and you
will find lots of blah blah there.

Into this:

And to get to the blah blah site please go to <a
href="http://blah-blah.com">http://blah-blah.com</aand you will find lots
of blah blah there.

It needs to be versatile as they may enter more than one http link within
the text.

Any help appreciated!

Sergio.
Jul 5 '06 #1
2 1512
Sergio Orrego wrote on 05 jul 2006 in
microsoft.public.inetserver.asp.general:
I have a text string which comes from a form containing the article
text in a knowledgebase. Sometimes people enter http links in their
text however when they show on the webpage they do not show as
hyperlinks, because obviously they don't gave the link tags around
them.

What I'd like is to manipulate this text string so that wherever there
is http in it it put's the link tags around it. So what I'm really
asking is, how can I convert this string:

And to get to the blah blah site please go to http://blah-blah.com and
you will find lots of blah blah there.

Into this:

And to get to the blah blah site please go to <a
href="http://blah-blah.com">http://blah-blah.com</aand you will find
lots of blah blah there.

It needs to be versatile as they may enter more than one http link
within the text.
That is easy, find seperate words commencing with http:// and convert those
words to the requested string and replace.

But how can you access "their text" in serverside ASP?
Where is "their text" located?

Please show what you have done sofar in ASP, either vbs or js.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 5 '06 #2

Sergio Orrego wrote:
I have a text string which comes from a form containing the article text in
a knowledgebase. Sometimes people enter http links in their text however
when they show on the webpage they do not show as hyperlinks, because
obviously they don't gave the link tags around them.

What I'd like is to manipulate this text string so that wherever there is
http in it it put's the link tags around it. So what I'm really asking is,
how can I convert this string:

And to get to the blah blah site please go to http://blah-blah.com and you
will find lots of blah blah there.

Into this:

And to get to the blah blah site please go to <a
href="http://blah-blah.com">http://blah-blah.com</aand you will find lots
of blah blah there.

It needs to be versatile as they may enter more than one http link within
the text.

Any help appreciated!
Try this pair of functions:

<%
function create_links(strText)
strText = " " & strText
strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)",
"$1<a href=""$2"" target=""_blank"">$2</a>")
strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)",
"$1<a href=""http://$2"" target=""_blank"">$2</a>")
strText = ereg_replace(strText, "(^|[\n
])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)", "$1<a
href=""mailto:$2@$3"">$2@$3</a>")
strText = right(strText, len(strText)-1)
create_links = strText
end function

function ereg_replace(strOriginalString, strPattern, strReplacement)
' Function replaces pattern with replacement
dim objRegExp : set objRegExp = new RegExp
objRegExp.Pattern = strPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
set objRegExp = nothing
end function
%>

article_text = create_links(Request.Form("article_text"))

--
Mike Brind

Jul 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dim | last post by:
I found that C# has some buggy ways to process string across methods. I have a class with on global string var and a method where i add / remove from this string Consider it a buffer... with some...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
10
by: micklee74 | last post by:
hi if i have a some lines like this a ) "here is first string" b ) "here is string2" c ) "here is string3" When i specify i only want to print the lines that contains "string" ie the first...
5
by: Niyazi | last post by:
Hi, Does anyone knows any good code for string manipulation similar to RegularExpresion? I might get a value as string in a different format. Example: 20/02/2006 or 20,02,2006 or ...
3
by: crprajan | last post by:
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) . So the output of the string will be “This is...
7
Frinavale
by: Frinavale | last post by:
I currently have a .NET application that has an object which passes a string (a connection string) as a parameter to another object that does database manipulation. This string isn't stored...
3
by: frankeljw | last post by:
I have 2 Java strings 1st String is a series of names, colons, and numbers ie) Name1:13:Name2:4526:Name3:789:Name4:3729:Name5:6:Name6:44 2nd String is a name ie) Name2 I need to get the...
22
by: mann_mathann | last post by:
can anyone tell me a solution: i cannot use the features in standard c++ string classgh i included the string.h file but still its not working.
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.