Using the WYSIWYG contenteditable feature, Internet Explorer will often
add a style to the image tag to define its display size after the image
has been dragged to display at something other than its natural size.
For example:
style="WIDTH: 432px; HEIGHT: 344px"
The values contained within the style are the correct ones resulting
from the drag and override the standard img tag height= and width=
parameters still remaining in the image tag.
I am seeking a regex that will read the values within the added style
portion of the tag, remove the style parameter, and leaving everything
else the same rewrite the tag with assignment of the width and height
values within the style to the standard width= and height= parameters.
For example, change this:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height=442 hspace=10
src='http://theimgurl/filename.jpg"; width=612 align=middle vspace=10
border=0>
to this:
<IMG height=344 hspace=10 src='http://theimgurl/filename.jpg";
width=432 align=middle vspace=10 border=0>
Will that be possible? It seems like it would be a very complex regex
well beyond my skills and possibly my brainpower but I'd be willing to
give it a try if it is technically possible.
The purpose is that under certain circumstances the presence of the
style breaks page layouts in older browsers. I'm not sure, but also if
a browser does not have styles on then the image would appear in the
unintended size, right?
Thanks!
Rob 5 2272 bl*******@aol.c om wrote: Using the WYSIWYG contenteditable feature, Internet Explorer will often add a style to the image tag to define its display size after the image has been dragged to display at something other than its natural size. For example:
style="WIDTH: 432px; HEIGHT: 344px"
The values contained within the style are the correct ones resulting from the drag and override the standard img tag height= and width= parameters still remaining in the image tag.
I am seeking a regex that will read the values within the added style portion of the tag, remove the style parameter, and leaving everything else the same rewrite the tag with assignment of the width and height values within the style to the standard width= and height= parameters.
Then all that is required is to remove the style attributes via
DOM, there is no need for any RegExp.
For example, change this:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height=442 hspace=10 src='http://theimgurl/filename.jpg"; width=612 align=middle vspace=10 border=0>
The following removes the style width & height attributes when
the image is clicked on, you may wish to do it from some other
event but the method is the same:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height="442"
hspace="10" src="http://theimgurl/filename.jpg";
width="612" align="middle" vspace="10" border="0"
onclick="
this.style.heig ht=null;
this.style.widt h=null;
">
Load the image, it will have the size given by the style
attributes, when clicked on, these are removed and the image
returns to the dimensions set by the image's width & height
attributes.
[...]
--
Rob
JRS: In article <11************ **********@o13g 2000cwo.googleg roups.com>
, dated Tue, 22 Mar 2005 20:22:13, seen in news:comp.lang. javascript, bl*******@aol.c om posted : I am seeking a regex that will read the values within the added style portion of the tag, remove the style parameter, and leaving everything else the same rewrite the tag with assignment of the width and height values within the style to the standard width= and height= parameters. For example, change this:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height=442 hspace=10 src='http://theimgurl/filename.jpg"; width=612 align=middle vspace=10 border=0>
to this:
<IMG height=344 hspace=10 src='http://theimgurl/filename.jpg"; width=432 align=middle vspace=10 border=0>
Will that be possible? It seems like it would be a very complex regex well beyond my skills and possibly my brainpower but I'd be willing to give it a try if it is technically possible.
You have not said whether your posting agent and/or technique have split
the <IMG ... > over more than one line. If that really is on one line,
then the following MiniTrue command line may be close to what you want
(it will be sent as a single line; how you see it is up to you and your
system) :
mtr -x+ $T.0 - "(<IMG) style=\x22WIDTH : (\d+)px; HEIGHT: (\d+)px\x22(.*h eight=)\d+(.*wi dth=)\d+" = \1\4\3\5\2
mtr is MiniTrue
-x+ (re-)enables RegExps;
$T.0 is a file containing much of your article
- is a separator
" are delimiters
= is a separator
\x22 stands for "
Pieces that you want to keep are in parentheses
..* means anything
\d+ means a number
\1 \4 \3 \5 \2 are back-references
It is assumed that WIDTH HEIGHT height width are always in that order;
if not, consider two passes.
If the original was on more than one line, I don't have time to deal with
that tonight; but it should not be an insuperable problem (especially if
always similarly split).
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelig ht.net/minitrue/> Update hope?
RobG wrote: bl*******@aol.c om wrote: Using the WYSIWYG contenteditable feature, Internet Explorer will
often add a style to the image tag to define its display size after the
image has been dragged to display at something other than its natural
size. For example:
style="WIDTH: 432px; HEIGHT: 344px"
The values contained within the style are the correct ones
resulting from the drag and override the standard img tag height= and width= parameters still remaining in the image tag.
I am seeking a regex that will read the values within the added
style portion of the tag, remove the style parameter, and leaving
everything else the same rewrite the tag with assignment of the width and
height values within the style to the standard width= and height=
parameters. Then all that is required is to remove the style attributes via DOM, there is no need for any RegExp.
For example, change this:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height=442 hspace=10 src='http://theimgurl/filename.jpg"; width=612 align=middle
vspace=10 border=0>
The following removes the style width & height attributes when the image is clicked on, you may wish to do it from some other event but the method is the same:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height="442" hspace="10" src="http://theimgurl/filename.jpg"; width="612" align="middle" vspace="10" border="0" onclick=" this.style.heig ht=null; this.style.widt h=null; ">
Load the image, it will have the size given by the style attributes, when clicked on, these are removed and the image returns to the dimensions set by the image's width & height attributes.
[...]
-- Rob
Thank you, I do need the sizes that are stored in the style, but you've
showed me how to get to those. Perhaps I can just capture all the
other expected attributes in the image tag via the DOM then just write
a whole new tag in place of the original. Should be easier than trying
to parse it.
Dr John Stockton wrote: JRS: In article
<11************ **********@o13g 2000cwo.googleg roups.com> , dated Tue, 22 Mar 2005 20:22:13, seen in news:comp.lang. javascript, bl*******@aol.c om posted : I am seeking a regex that will read the values within the added
styleportion of the tag, remove the style parameter, and leaving
everythingelse the same rewrite the tag with assignment of the width and
heightvalues within the style to the standard width= and height=
parameters.For example, change this:
<IMG style="WIDTH: 432px; HEIGHT: 344px" height=442 hspace=10 src='http://theimgurl/filename.jpg"; width=612 align=middle
vspace=10border=0>
to this:
<IMG height=344 hspace=10 src='http://theimgurl/filename.jpg"; width=432 align=middle vspace=10 border=0>
Will that be possible? It seems like it would be a very complex
regexwell beyond my skills and possibly my brainpower but I'd be willing
togive it a try if it is technically possible.
You have not said whether your posting agent and/or technique have
split the <IMG ... > over more than one line. If that really is on one
line, then the following MiniTrue command line may be close to what you
want (it will be sent as a single line; how you see it is up to you and
your system) :
mtr -x+ $T.0 - "(<IMG) style=\x22WIDTH : (\d+)px; HEIGHT:
(\d+)px\x22(.*h eight=)\d+(.*wi dth=)\d+" = \1\4\3\5\2 mtr is MiniTrue -x+ (re-)enables RegExps; $T.0 is a file containing much of your article - is a separator " are delimiters = is a separator \x22 stands for " Pieces that you want to keep are in parentheses .* means anything \d+ means a number \1 \4 \3 \5 \2 are back-references It is assumed that WIDTH HEIGHT height width are always in that
order; if not, consider two passes. If the original was on more than one line, I don't have time to deal
with that tonight; but it should not be an insuperable problem (especially
if always similarly split).
-- © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00
MIME. © Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms,
& links. I find MiniTrue useful for viewing/searching/altering files, at a
DOS prompt; free, DOS/Win/UNIX, <URL:http://www.idiotsdelig ht.net/minitrue/>
Update hope?
Thank you sir. I'll need to study what are and how to use
backreferences. That seems to be key.
JRS: In article <11************ **********@o13g 2000cwo.googleg roups.com>
, dated Wed, 23 Mar 2005 21:32:03, seen in news:comp.lang. javascript, bl*******@aol.c om posted : Thank you sir. I'll need to study what are and how to use backreferences . That seems to be key.
Study also the newsgroup FAQ section 3.2.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dean H. Saxe |
last post by:
I'm currently developing a tool in perl to search out potential XSS
(Cross Site Scripting) vulnerabilities and correct them in a
ColdFusion based web app. I've been having great success so far,
however, one scenario has me banging my head against the wall.
I need a regex to find all <cfoutput ...>...</cfoutput> blocks in a
CFM template. The regex should find all such blocks that are *not*
nested within HTML tags (the tag itself,...
|
by: G. Stewart |
last post by:
The objective is to extract the first n characters of text from an
HTML block. I wish to preserve all HTML (links, formatting etc.), and
at the same time, extend the size of the block to ensure that all
closing tags are recovered.
For example, simply extracting the first 400 characters of a HTML
block may result in an <i> opening tag being including, but its
closing tag being excluding. Or a link may get chopped halfway - may be the...
|
by: JKJ |
last post by:
I need help with a regular expression that will pull the
title and all the meta tags held in the head section of an
HTML file (including the head tags). I want to exclude
everything else such as link tags, script tags, etc. I
have a pretty big process that pulls this stuff now using
simple Regex expressions, but I know I'm not using the
Regex's to their fullest. . .
|
by: Natalia DeBow |
last post by:
Hi there,
I have another question for .NET RegEx experts.
I am reading in a C Sharp file line by line and I am trying to detect
comments that start with either // of ///. What I am particularly
interested is the comments themselves. I am interested in some stats with
regards to the amount of comments in the file (comment bytes).
So, I tried several regular expressions, but they don't seem to work in
|
by: DDK |
last post by:
I am trying to figure out how to Replace tags such as ... with the
correct HTML <b>...</b> tags in C#.
The code below works however only if one set of tags are found, if you have
more than two sets of the tags within the text it renders from the first .
Here is the code that doesn't quite work:
////////////////////////////////////////////////////////////////////////////
/////
| |
by: darrel |
last post by:
I have some vb.net code that is running a regex, matching groups, and
replacing them. I'm trying to come up with a simple script that will strip
all attributes from all HTML tags.
This is what I have:
=============================================================
function stripAllAttributes(ByVal textToParse as String, ByVal tagToFind as
String) as String
|
by: Chris Lieb |
last post by:
I am trying to write a regex that will parse BBcode into HTML using
JavaScript. Everything was going smoothly using the string class
replace() operator with regex's until I got to the list tag.
Implementing the list tag itself was fairly easy. What was not was
trying to handle the list items. For some reason, in BBcode, they
didn't bother defining an end tag for a list item. I guess that they
designed it with bad old HTML 3.2 in mind...
|
by: MrNobody |
last post by:
I'm trying to do some regex in C# but for some reason linebreaks are causing
my regex to not work.
the test string goes like this:
string ss = "<tagname
something=45678&somethingelse=12345>blah</tagname>\r\n<tag2>stuff</tag2>";
and my regex code is like:
|
by: GS |
last post by:
what is a good regex expression for remove html <img ....tag?
I tried
"<img *\->", RegexOptions.IgnoreCase)
but it is not quite working
thank you for your time
|
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...
|
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,...
| |
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |