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"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><embed src="URL"
type="application/x-shockwave-flash" wmode="transparent" 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 1344
On May 10, 9:37*pm, Rauan Maemirov <rauan1...@gmail.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"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><embed src="URL"
type="application/x-shockwave-flash" wmode="transparent" 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"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><embed src="URL"
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><img src="URL"
type="application/x-shockwave-flash" wmode="transparent" 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"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><embed src="URL"
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><img src="URL"
type="application/x-shockwave-flash" wmode="transparent" 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.prototype.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...@web.de>
wrote:
Rauan Maemirov wrote:
I tried to do it myself, but all I did is to replaced
<object width="425" height="355"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><embed src="URL"
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><img src="URL"
type="application/x-shockwave-flash" wmode="transparent" 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.prototype.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"><param name="movie"
value="http://www.youtube.com/v/yVjzd320gew&hl=en"></param><param
name="wmode" value="transparent"></param><embed src="http://
www.youtube.com/v/yVjzd320gew&hl=en" type="application/x-shockwave-
flash" wmode="transparent" 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...@web.de>
wrote:
Rauan Maemirov wrote:
I tried to do it myself, but all I did is to replaced
<object width="425" height="355"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><embed src="URL"
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="355"></embed></object>
with
<object width="425" height="355"><param name="movie" value="URL"></
param><param name="wmode" value="transparent"></param><img src="URL"
type="application/x-shockwave-flash" wmode="transparent" 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.prototype.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"><param name="movie" value="URL"></ param><param name="wmode" value="transparent"></param><embed src="URL" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object> with <object width="425" height="355"><param name="movie" value="URL"></ param><param name="wmode" value="transparent"></param><img src="URL" type="application/x-shockwave-flash" wmode="transparent" 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.prototype.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"><param name="movie"
value="http://www.youtube.com/v/yVjzd320gew&hl=en"></param><param
name="wmode" value="transparent"></param><embed src="http://
www.youtube.com/v/yVjzd320gew&hl=en" type="application/x-shockwave-
flash" wmode="transparent" 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...@web.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"><param name="movie" value="URL"></ param><param name="wmode" value="transparent"></param><embed src="URL" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object> with <object width="425" height="355"><param name="movie" value="URL"></ param><param name="wmode" value="transparent"></param><img src="URL" type="application/x-shockwave-flash" wmode="transparent" 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.prototype.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"><param name="movie"
value="http://www.youtube.com/v/yVjzd320gew&hl=en"></param><param
name="wmode" value="transparent"></param><embed src="http://
www.youtube.com/v/yVjzd320gew&hl=en" type="application/x-shockwave-
flash" wmode="transparent" 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>...<embed src="title".../></
object>...<object>...<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...
|
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' )
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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 ...
| |