Hi, all. I'm trying to replace <object ...><embed... /></objectwith
<imgtag and vice-verse. It's like implementation of media plugin of
Tiny MCE editor. I tried to watch their code, but it's too complicated
and has a lot of unnecessary code. And the main reason is i'm weak in
javascript rewriting. :)
I need just simple rewrite for e.g. this
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><embed src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
<img width="425" height="355" title="src:'URL '">.
param tags can be omitted.
Could anybody help me? Thanks in advance. 6 1377
On May 10, 9:37*pm, Rauan Maemirov <rauan1...@gmai l.comwrote:
Hi, all. I'm trying to replace <object ...><embed... /></objectwith
<imgtag and vice-verse. It's like implementation of media plugin of
Tiny MCE editor. I tried to watch their code, but it's too complicated
and has a lot of unnecessary code. And the main reason is i'm weak in
javascript rewriting. :)
I need just simple rewrite for e.g. this
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><embed src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
<img width="425" height="355" title="src:'URL '">.
param tags can be omitted.
Could anybody help me? Thanks in advance.
I tried to do it myself, but all I did is to replaced
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><embed src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><img src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
Rauan Maemirov wrote:
I tried to do it myself, but all I did is to replaced
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><embed src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><img src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
1. My tests indicate that a Flash movie is not played by an `img' element,
so replacing the object-embed element combination would be futile, even
though the `embed' element is proprietary (and therefore not Valid).
2. Using client-side scripting to correct markup is the wrong approach
as it does not need to be available.
3. If necessary, you should rewrite the editor instead.
4. FWIW, in Eclipse I would have used the following parameters:
Search for:
(?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s+(width=.+? >)</embed></object>
Replace with:
<img $1 $2 alt="">
(Don't forget the `alt' attribute, give it a descriptive value if
possible/applicable!)
BTW, QuickREx again came in handy in finding that out:
<http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html>
5. With the exception of `(?s)', which can be worked around with
`(?:.|[\r\n])' instead of `.', this should also work with
String.prototyp e.replace() in JavaScript 1.5+ (Mozilla/5.0),
JScript 5.5+ (IE 5.5+), ECMAScript Ed. 3+.
6. Replacing content this way might require using `innerHTML', a
proprietary property that should be avoided in favor of DOM 2 scripting.
HTH
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
On May 12, 4:43*am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
Rauan Maemirov wrote:
I tried to do it myself, but all I did is to replaced
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><embed src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><img src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
1. My tests indicate that a Flash movie is not played by an `img' element,
* *so replacing the object-embed element combination would be futile, even
* *though the `embed' element is proprietary (and therefore not Valid)..
2. Using client-side scripting to correct markup is the wrong approach
* *as it does not need to be available.
3. If necessary, you should rewrite the editor instead.
4. FWIW, in Eclipse I would have used the following parameters:
Search for:
(?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s+(width=.+? >)</embed></object>
Replace with:
<img $1 $2 alt="">
(Don't forget the `alt' attribute, give it a descriptive value if
possible/applicable!)
BTW, QuickREx again came in handy in finding that out:
<http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html>
5. With the exception of `(?s)', which can be worked around with
* *`(?:.|[\r\n])' instead of `.', this should also work with
* *String.prototy pe.replace() in JavaScript 1.5+ (Mozilla/5.0),
* *JScript 5.5+ (IE 5.5+), ECMAScript Ed. 3+.
6. Replacing content this way might require using `innerHTML', a
* *proprietary property that should be avoided in favor of DOM 2 scripting.
HTH
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
I tried your regex:
var flash = '<object width="425" height="355"><p aram name="movie"
value="http://www.youtube.com/v/yVjzd320gew&hl= en"></param><param
name="wmode" value="transpar ent"></param><embed src="http://
www.youtube.com/v/yVjzd320gew&hl= en" type="applicati on/x-shockwave-
flash" wmode="transpar ent" width="425" height="355"></embed></
object>';
flash = flash.replace(' (?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s
+(width=.+?>)</embed></object>', '<img $1 $2 alt=""');
It returns the same object...
On May 12, 4:43*am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
Rauan Maemirov wrote:
I tried to do it myself, but all I did is to replaced
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><embed src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><p aram name="movie" value="URL"></
param><param name="wmode" value="transpar ent"></param><img src="URL"
type="applicati on/x-shockwave-flash" wmode="transpar ent" width="425"
height="355"></embed></object>
1. My tests indicate that a Flash movie is not played by an `img' element,
* *so replacing the object-embed element combination would be futile, even
* *though the `embed' element is proprietary (and therefore not Valid)..
2. Using client-side scripting to correct markup is the wrong approach
* *as it does not need to be available.
3. If necessary, you should rewrite the editor instead.
4. FWIW, in Eclipse I would have used the following parameters:
Search for:
(?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s+(width=.+? >)</embed></object>
Replace with:
<img $1 $2 alt="">
(Don't forget the `alt' attribute, give it a descriptive value if
possible/applicable!)
BTW, QuickREx again came in handy in finding that out:
<http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html>
5. With the exception of `(?s)', which can be worked around with
* *`(?:.|[\r\n])' instead of `.', this should also work with
* *String.prototy pe.replace() in JavaScript 1.5+ (Mozilla/5.0),
* *JScript 5.5+ (IE 5.5+), ECMAScript Ed. 3+.
6. Replacing content this way might require using `innerHTML', a
* *proprietary property that should be avoided in favor of DOM 2 scripting.
HTH
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
I tried to use QuickREx (application, that U noticed) and indeed, it
show matches correct. But in javascript it doesn't replace my text at
all.
[trimmed attribution novel]
Rauan Maemirov wrote:
Thomas 'PointedEars' Lahn wrote:
>Rauan Maemirov wrote:
>>I tried to do it myself, but all I did is to replaced <object width="425" height="355"><p aram name="movie" value="URL"></ param><para m name="wmode" value="transpar ent"></param><embed src="URL" type="applica tion/x-shockwave-flash" wmode="transpar ent" width="425" height="355"> </embed></object> with <object width="425" height="355"><p aram name="movie" value="URL"></ param><para m name="wmode" value="transpar ent"></param><img src="URL" type="applica tion/x-shockwave-flash" wmode="transpar ent" width="425" height="355"> </embed></object>
[...] 4. FWIW, in Eclipse I would have used the following parameters:
Search for: (?s)<object\s+ .*?<embed\s+.*? (src=".+?")[^>]*?\s+(width=.+? >)</embed></object>
Replace with: <img $1 $2 alt="">
(Don't forget the `alt' attribute, give it a descriptive value if possible/applicable!)
BTW, QuickREx again came in handy in finding that out: <http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html>
5. With the exception of `(?s)', which can be worked around with `(?:.|[\r\n])' instead of `.', this should also work with String.prototyp e.replace() in JavaScript 1.5+ (Mozilla/5.0), JScript 5.5+ (IE 5.5+), ECMAScript Ed. 3+. [...]
I tried your regex:
var flash = '<object width="425" height="355"><p aram name="movie"
value="http://www.youtube.com/v/yVjzd320gew&hl= en"></param><param
name="wmode" value="transpar ent"></param><embed src="http://
www.youtube.com/v/yVjzd320gew&hl= en" type="applicati on/x-shockwave-
flash" wmode="transpar ent" width="425" height="355"></embed></
object>';
flash = flash.replace(' (?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s
+(width=.+?>)</embed></object>', '<img $1 $2 alt=""');
It returns the same object...
It returns a primitive string value, not an object. It returns the same
string it is being applied to because you have not passed a RegExp object
but a string as argument, and you have not read my posting thoroughly
enough. If you had quoted properly, you would have been forced to re-read
before replying and had probably not made this silly mistake.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
On May 12, 4:58*pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
[trimmed attribution novel]
Rauan Maemirov wrote:
Thomas 'PointedEars' Lahn wrote:
Rauan Maemirov wrote: I tried to do it myself, but all I did is to replaced <object width="425" height="355"><p aram name="movie" value="URL"></ param><param name="wmode" value="transpar ent"></param><embed src="URL" type="applicat ion/x-shockwave-flash" wmode="transpar ent" width="425" height="355" ></embed></object> with <object width="425" height="355"><p aram name="movie" value="URL"></ param><param name="wmode" value="transpar ent"></param><img src="URL" type="applicat ion/x-shockwave-flash" wmode="transpar ent" width="425" height="355" ></embed></object>
[...]
4. FWIW, in Eclipse I would have used the following parameters:
Search for:
(?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s+(width=.+? >)</embed></object>
Replace with:
<img $1 $2 alt="">
(Don't forget the `alt' attribute, give it a descriptive value if
possible/applicable!)
BTW, QuickREx again came in handy in finding that out:
<http://www.bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html>
5. With the exception of `(?s)', which can be worked around with
* *`(?:.|[\r\n])' instead of `.', this should also work with
* *String.prototy pe.replace() in JavaScript 1.5+ (Mozilla/5.0),
* *JScript 5.5+ (IE 5.5+), ECMAScript Ed. 3+.
[...]
I tried your regex:
var flash = '<object width="425" height="355"><p aram name="movie"
value="http://www.youtube.com/v/yVjzd320gew&hl= en"></param><param
name="wmode" value="transpar ent"></param><embed src="http://
www.youtube.com/v/yVjzd320gew&hl= en" type="applicati on/x-shockwave-
flash" wmode="transpar ent" width="425" height="355"></embed></
object>';
flash = flash.replace(' (?s)<object\s+. *?<embed\s+.*?( src=".+?")[^>]*?\s
+(width=.+?>)</embed></object>', '<img $1 $2 alt=""');
It returns the same object...
It returns a primitive string value, not an object. *It returns the same
string it is being applied to because you have not passed a RegExp object
but a string as argument, and you have not read my posting thoroughly
enough. *If you had quoted properly, you would have been forced to re-read
before replying and had probably not made this silly mistake.
PointedEars
--
* * realism: * *HTML 4.01 Strict
* * evangelism: XHTML 1.0 Strict
* * madness: * *XHTML 1.1 as application/xhtml+xml
* * * * * * * * * * * * * * * * * * * * * * * * * * -- Bjoern Hoehrmann
Thanks, Thomas. I found my mistake. But there is the next trouble.
What if I have more than one <object>'s. It returns only one image. I
need to construct regexp the way, that it will replace only one
node(tag). E.g. <object>...<emb ed src="title".../></
object>...<obje ct>...<embed ... width="455".../></object> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Westcoast Sheri |
last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database
(2 columns: "fruit" and "quantity")....so can we make these following
mySQL queries work somehow?
(visitor buys 5 apples):
replace into fruit_database set fruit = 'apple' , quantity = quantity +
5;
(visitor buys 7 apples):
replace into fruit_database set fruit = 'apple' , quantity = quantity +
|
by: Roose |
last post by:
How can I do a "".replace operation which tells me if anything was
actually replaced?
Right now I am doing something like:
if searchTerm in text:
text = text.replace( searchTerm, 'other' )
But to me this seems inefficient since the 'in' operation will search
through the whole string, and then the 'replace' will as well.
|
by: rbt |
last post by:
Here's the scenario:
You have many hundred gigabytes of data... possible even a terabyte or
two. Within this data, you have private, sensitive information (US
social security numbers) about your company's clients. Your company has
generated its own unique ID numbers to replace the social security numbers.
Now, management would like the IT guys to go thru the old data and
replace as many SSNs with the new ID numbers as possible. You...
|
by: higabe |
last post by:
Three questions
1)
I have a string function that works perfectly but according to W3C.org
web site is syntactically flawed because it contains the characters </
in sequence. So how am I supposed to write this function?
String.replace(/</g,'<');
|
by: Andy Sutorius |
last post by:
Hi,
I read the thread (2/16/05) regarding a replace function in C# however it
didn't answer my question. I have a string which is building an insert sql
statement and I would like to replace apostrophes of the form fields. I was
trying to do something like this:
string sqlInsertEmails = "insert into tblContent (content, subject) values
('" + Replace(txtBody.Text,"'","''") + "', '" +
Replace(txtSubject.Text,"'","''") + "')";
| |
by: Peter Row |
last post by:
Hi,
I know this has been asked before, but reading the threads it is still not
entirely clear.
Deciding which .Replace( ) to use when.
Typically if I create a string in a loop I always use a StringBuilder. At
present I am
porting a VB6 webclass app to VB.NET and therefore I am trying to make it as
efficent as possible via the new functionality of VB.NET.
|
by: djc |
last post by:
I need to prepare a large text database field to display in an asp.net
repeater control. Currently I am replacing all chr(13)'s with a "<br/>" and
it works fine. However, now I also want to be able to replace TAB's with
" "'s to preserve the user's indentation. My questions are:
1) even though I'll probably look it up before I get a reply.... whats the
vb code for TAB character?
2) more importantly; do I have to run this large field...
|
by: Joe Cool |
last post by:
I need to map several columns of data from one database to another
where the data contains multiple spaces (once occurance of a variable
number or spaces) that I need to replace with a single space. What
would be the most efficient way to do this? I am using SQL2K. I was
thinking a function since I know of no single Transact-SQL command
that can accomplish this task.
|
by: alainfri |
last post by:
I am not sure if this group is the right place for this question but
what I need is as follows. There is a piece of html. Throughout the
html there are a lot of <brtags. The task is to replace all these
<brtags with \n\r. The replacement must be performed only within
<preblocks. I can do this using VBScript in the following way:
Option Explicit
|
by: =?Utf-8?B?TWlrZSAiWU9fQkVFIiBC?= |
last post by:
I have a text file that contains about 8 to 10 text sequences that I need to
replace.
I want to search and replace all 8 to 10 text sequence anytime I run this
script
Here is what I have so far.
Const ForReading = 1
Const ForWriting = 2
|
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: 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...
|
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...
| |