473,396 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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;">Underlined bold &
italic!! </span> just italic</span> now bold again </span>not bold<br />

Can anyone help?

Cheers

David Henderson
Jul 19 '05 #1
9 1909
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**************@TK2MSFTNGP10.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**************@TK2MSFTNGP15.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.net...
:> ...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.net...
:
: > : 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
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...
5
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....
12
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...
3
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...
2
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
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...
2
by: howa | last post by:
anyone heard that before?
1
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...
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.