473,811 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1576
Sergio Orrego wrote on 05 jul 2006 in
microsoft.publi c.inetserver.as p.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(st rText)
strText = " " & strText
strText = ereg_replace(st rText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)",
"$1<a href=""$2"" target=""_blank "">$2</a>")
strText = ereg_replace(st rText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)",
"$1<a href=""http://$2"" target=""_blank "">$2</a>")
strText = ereg_replace(st rText, "(^|[\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(st rOriginalString , strPattern, strReplacement)
' Function replaces pattern with replacement
dim objRegExp : set objRegExp = new RegExp
objRegExp.Patte rn = strPattern
objRegExp.Ignor eCase = True
objRegExp.Globa l = True
ereg_replace = objRegExp.repla ce(strOriginalS tring, strReplacement)
set objRegExp = nothing
end function
%>

article_text = create_links(Re quest.Form("art icle_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
2279
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 values and separators class { private string globalvar = ""; private void manipulate (whattodo ) //substring, join, etc....
32
14918
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 ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
29
4329
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 substring before a pattern), AFTER (return substring after a pattern), and BETWEEN (return substring between 2 patterns). My questions are: 1. Can any tell me how I can implement such functionality in C#? 2. Is it possible to add/include function...
4
3497
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 substrings need be replaced, or one character needs be changed, what shall I do? Is it better to convert strings to UCS-32 before manipulation? But on Windows, wchar_t is 16 bits which isn't enough for characters which can't be simply encoded...
10
1778
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 line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple
5
7497
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 20.02.2006 etc... And I want to replace the /,.etc character with - (as 20-02-2006)
3
1566
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 string” This is very urgent. Please help
7
2108
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 anywhere else and is only used by this behind-the-scenes object to provide the database manipulation object with a connection string. Does my connection string pose a security problem when it is inside the code like this? Or are connection strings...
3
3567
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 number associated with that name.
22
2628
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.
0
9730
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10403
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.