473,769 Members | 7,315 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replacing span tags

Hi There...

I'm struggling with a problem:
I have a string (coming from a rich text editor) which contains a variety of
span tags that need to be replaced with corresponding formatting tags.
e.g.

<span style="font-weight: bold;">line 2</span>

needs to become
<b>line 2</b>

So... with a single set of tags its simple. But then when you add in the
underline and italic <span> tags it becomes a right mess - especially if you
get nested tags which means you can't just replace the next </span> tag with
the relevant formatting closing tag as it could be the closing tag from
another nested tag.

e.g.

<span style="font-weight: bold;">bold and <span style="font-style:
italic;">italic <span style="text-decoration: underline;">Und erlined bold &
italic!! </span> just italic</span> now bold again </span>not bold<br />

Can anyone help?

Cheers

David Henderson
Jul 19 '05 #1
9 1933
Hi David,

Confused as to why this needs to be done, whats wrong with span tags?
But, you would need to write your own function to acheive the desired
results.

Read up on searching with regular expressions, and the replace() function.

Tom
Jul 19 '05 #2
"Thomas Gullen" wrote in message news:41******** ******@drum-world.com...
: Confused as to why this needs to be done, whats wrong with span tags?
: But, you would need to write your own function to acheive the desired
: results.
:
: Read up on searching with regular expressions, and the replace() function.

....and how is this asp related?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #3
What, are you the off-topic OD today?

I would venture to say the question and answer given are more ASP-related
than *your* answer. How was that ASP-related?

Bob Lehmann

"Roland Hall" <nobody@nowhere > wrote in message
news:ez******** ******@TK2MSFTN GP10.phx.gbl...
"Thomas Gullen" wrote in message news:41******** ******@drum-world.com...
: Confused as to why this needs to be done, whats wrong with span tags?
: But, you would need to write your own function to acheive the desired
: results.
:
: Read up on searching with regular expressions, and the replace() function.
...and how is this asp related?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 19 '05 #4
> ...and how is this asp related?

I'd attempted an asp solution and was looking for any ideas relating to
one... so seems fairly related to me ;-)

David Henderson
Jul 19 '05 #5
"Thomas Gullen" <ad***@drum-world.com> wrote in message
news:41******** ******@drum-world.com...
Hi David,

Confused as to why this needs to be done, whats wrong with span tags?
But, you would need to write your own function to acheive the desired
results.

Read up on searching with regular expressions, and the replace() function.

Tom


In addition to Tom's suggestion, you may also want to consider XSLT if the
data is well formed(i.e. valid XML). As you've already alluded to, regular
expressions are linear in nature and as such are not well suited to nested
structures.
Jul 19 '05 #6
"Bob Lehmann" wrote in message news:eD******** ******@TK2MSFTN GP15.phx.gbl...
: What, are you the off-topic OD today?

Bob...

Show me the ASP related code in this post.

: I would venture to say the question and answer given are more ASP-related
: than *your* answer. How was that ASP-related?

You're just too quick Bob however, I didn't provide an answer. I only asked
a question. Your response is of no use. But, to answer your ridiculous
question, I'll provide a ridiculous answer. My question at least had the
word ASP included. Happy now?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #7
"David Henderson" wrote in message
news:41******** *************** @ptn-nntp-reader04.plus.n et...
:> ...and how is this asp related?
:
: I'd attempted an asp solution and was looking for any ideas relating to
: one... so seems fairly related to me ;-)

Sorry Dave...

I don't see anything related to ASP other than it's in this NG. You have
only provided client-side code AFAICT. I only see inline styles with DOM
related HTML.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #8
: I'd attempted an asp solution and was looking for any ideas relating to
: one... so seems fairly related to me ;-)

Sorry Dave...

I don't see anything related to ASP other than it's in this NG. You have
only provided client-side code AFAICT. I only see inline styles with DOM
related HTML.


Its OK Roland... I'll forgive you for not being a mind reader!
I was originally going to post my attempt(s) but
a) they didnt come close to working
b) they were badly put together
c) they were huge

So I decided for the sanity of everyone else not to. I was really just
looking for some pointers towarrds a method... but I've sorted it out now
anyway!

Sorry to be a pain in the ass!

David Henderson
Jul 19 '05 #9
"David Henderson" wrote in message
news:41******** *************** @ptn-nntp-reader04.plus.n et...
:
: > : I'd attempted an asp solution and was looking for any ideas relating
to
: > : one... so seems fairly related to me ;-)
: >
: > Sorry Dave...
: >
: > I don't see anything related to ASP other than it's in this NG. You
have
: > only provided client-side code AFAICT. I only see inline styles with
DOM
: > related HTML.
: >
:
: Its OK Roland... I'll forgive you for not being a mind reader!
: I was originally going to post my attempt(s) but
: a) they didnt come close to working
: b) they were badly put together
: c) they were huge
:
: So I decided for the sanity of everyone else not to. I was really just
: looking for some pointers towarrds a method... but I've sorted it out now
: anyway!
:
: Sorry to be a pain in the ass!

Dave...

Clarification via a discussion does not make one a pain in the ass. If your
code worked you wouldn't be asking for advice. You should probably never
post all of your code but rather relevant code regarding your issue. If
someone needs more info to help, they'll usually ask. I come here to gain
knowledge and help where I can. Sometimes I'm successful. In this case, I
needed more information because you're right, I'm not a mind reader but I
play one on TV.

Glad you got a handle on your issue and thanks for responding.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #10

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

Similar topics

2
11945
by: Eric Cota | last post by:
I have a page which has multiple span tags, I would like a javascript function that can look at each of these span tags for me. Depending on the what the user is doing there could be a different number of span tags so I don't want to hard code them. Thanks Eric
5
29606
by: Kathryn | last post by:
Good morning! I am having a problem with a span. I have items, of which I only want to show the first X characters on the screen. If the user prints the page, I want the entire item to print. Thanks to Els, I have a way to do this, see below, directly from the View Source: This is a long piece of text. This is a long piece of text. This
12
5227
by: Oberon | last post by:
I have a large HTML document. It has hundreds of <span>s which have no attributes so these <span>s are redundant. How can I remove these tags automatically? The document also has <span>s with style attributes that I don't want to remove.
3
3779
by: jumblesale | last post by:
Hello all, I'm not all that bad at Regex, but i'm stumped on how to approach my problem. I need to parse a string and remove all html tags except hyperlinks. I can remove all the html tags using: Regex.Replace(inputText, @"<(/?+)>", ""); But this also removes any hyperlinks, which i need to keep.
2
5246
by: shapper | last post by:
Hello, Is there any validation problem using a <por a <h1tags inside a <spantag as follows: <span><p>Something</p><span> or <span><h1>Something</h1><span>
1
1348
by: godrifle | last post by:
I hope this is the best way to explain what I'm trying to do, using PHP5. Given the following HTML sample... <html><head><title>The Page</title></head> <body> <h2>A Title</h2> <img alt="zfMs|SCRIPTURE|1COL1ROW" src="./scripture.gif" style="left: 507px; position: absolute; top: 85px;" /> <p><strong>Some descriptive text</strong></p> <img src="this.gif" alt="An image" />
2
4697
by: howa | last post by:
anyone heard that before?
1
4248
by: jprimo | last post by:
Hi Everyone, I was wondering if anyone knew how to disable to span tags that appear in the place of ASP.NET labels ( <asp:Label ) after it has been processed by the server. I have a style sheet that I am trying to apply to a web page and these span tags are causing problems. I am using C# for my codebehind file. Any help is appreciated. Thanks
6
3227
by: mangal | last post by:
Hi, I need of assistance to convert spans having style related bold, ital and underline & color into html bold, underline and/or italicize tags. Sample Input String: <p>In <span style="font-family:'serif', 'Caslon'; font-size:11pt; font-style:italic; color:#221E1F">The Crack in the Cosmic Egg</span> I recounted how, at a gathering of dor mitory mates around a table, <span style="font-family:'serif', 'Caslon'; font-size:11pt;...
0
9589
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
10049
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
9998
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
9865
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...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.