Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: replace que...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 7 Topic 35557 of 37128
Post > Topic >>

Re: replace question

by Rauan Maemirov <rauan1987@[EMAIL PROTECTED] > May 14, 2008 at 03:43 AM

On May 12, 4:58=A0pm, Thomas 'PointedEars' Lahn <PointedE...@[EMAIL PROTECTED]
>
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=3D"425" height=3D"355"><param name=3D"movie"
value=3D"UR=
L"></
> >>> param><param name=3D"wmode" value=3D"transparent"></param><embed
src=
=3D"URL"
> >>> type=3D"application/x-shockwave-flash" wmode=3D"transparent"
width=3D"=
425"
> >>> height=3D"355"></embed></object>
> >>> with
> >>> <object width=3D"425" height=3D"355"><param name=3D"movie"
value=3D"UR=
L"></
> >>> param><param name=3D"wmode" value=3D"transparent"></param><img
src=3D"=
URL"
> >>> type=3D"application/x-shockwave-flash" wmode=3D"transparent"
width=3D"=
425"
> >>> height=3D"355"></embed></object>
> >> [...]
> >> 4. FWIW, in Eclipse I would have used the following parameters:
>
> >> Search for:
> >>
(?s)<object\s+.*?<embed\s+.*?(src=3D".+?")[^>]*?\s+(width=3D.+?>)</embe=
d></object>
>
> >> Replace with:
> >> <img $1 $2 alt=3D"">
>
> >> (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.ht=
ml>
>
> >> 5. With the exception of `(?s)', which can be worked around with
> >> =A0 =A0`(?:.|[\r\n])' instead of `.', this should also work with
> >> =A0 =A0String.prototype.replace() in JavaScript 1.5+ (Mozilla/5.0),
> >> =A0 =A0JScript 5.5+ (IE 5.5+), ECMAScript Ed. 3+.
> >> [...]
>
> > I tried your regex:
>
> > var flash =3D '<object width=3D"425" height=3D"355"><param
name=3D"movie=
"
> > value=3D"http://www.youtube.com/v/yVjzd320gew&hl=3Den"></param><param
> > name=3D"wmode" value=3D"transparent"></param><embed src=3D"http://
> >www.youtube.com/v/yVjzd320gew&hl=3Den" type=3D"application/x-shockwave-
> > flash" wmode=3D"transparent" width=3D"425" height=3D"355"></embed></
> > object>';
>
> > flash =3D
flash.replace('(?s)<object\s+.*?<embed\s+.*?(src=3D".+?")[^>]*=
?\s
> > +(width=3D.+?>)</embed></object>', '<img $1 $2 alt=3D""> ');
>
> > It returns the same object...
>
> It returns a primitive string value, not an object. =A0It 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. =A0If you had quoted properly, you would have been forced to
re-re=
ad
> before replying and had probably not made this silly mistake.
>
> PointedEars
> --
> =A0 =A0 realism: =A0 =A0HTML 4.01 Strict
> =A0 =A0 evangelism: XHTML 1.0 Strict
> =A0 =A0 madness: =A0 =A0XHTML 1.1 as application/xhtml+xml
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- 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=3D"title".../></
object>...<object>...<embed ... width=3D"455".../></object>
 




 7 Posts in Topic:
replace question
Rauan Maemirov <rauan1  2008-05-10 08:37:52 
Re: replace question
Rauan Maemirov <rauan1  2008-05-11 11:45:01 
Re: replace question
Thomas 'PointedEars' Lahn  2008-05-12 00:43:29 
Re: replace question
Rauan Maemirov <rauan1  2008-05-12 02:03:03 
Re: replace question
Thomas 'PointedEars' Lahn  2008-05-12 12:58:53 
Re: replace question
Rauan Maemirov <rauan1  2008-05-12 03:52:40 
Re: replace question
Rauan Maemirov <rauan1  2008-05-14 03:43:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 15:03:52 CDT 2008.