<script>
var str='..........................'; //你上边的一大串字符
var arr=str.match(/src=\".+\"/gi);
var result='';
for(var i=0;i<arr.length;i++)
{
result+=('<img '+arr[i]+'><br>');
} alert(result);
</script>
var str='..........................'; //你上边的一大串字符
var arr=str.match(/src=\".+\"/gi);
var result='';
for(var i=0;i<arr.length;i++)
{
result+=('<img '+arr[i]+'><br>');
} alert(result);
</script>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图片</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">1 <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype></FONT><v:shape id=_x0000_i1025 style="WIDTH: 48pt; HEIGHT: 48pt" type="#_x0000_t75"><v:imagedata o:title="squall" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image000.gif"></v:imagedata></v:shape></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图片</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">2</FONT><v:shape id=_x0000_i1026 style="WIDTH: 48pt; HEIGHT: 48pt" type="#_x0000_t75"><FONT face="Times New Roman"> <v:imagedata o:title="squall" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.gif"></v:imagedata></FONT></v:shape></SPAN></P>
<P> </P>
</textarea>
<textarea name=t2></textarea>
<input type=button onclick="t2.value=cleanAndPaste(t1.value)">
<script>
function cleanAndPaste( html ) {
// Remove all SPAN tags
html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
// Remove Class attributes
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove Style attributes
html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
// Remove Lang attributes
html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove XML elements and declarations
html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
// Remove Tags with XML namespace declarations: <o:p></o:p>
html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
// Replace the
html = html.replace(/ /, " " );
// Transform <P> to <DIV>
var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
html = html.replace( re, "<div$2</div>" ) ;
return html;
}
</script>
vivianfdlpw() :图片可以得到了,但文字如何得到呢?
scoutlin(梅川库子):文字是得到了,但图片又如何得到呢?
hhjjhjhj(大头)(想变胡萝卜^^):如果用程序如何实现呢再谢各们高手,帮我解决下我的问题!
var arr=str.match(/src=\".+\"/gi);
var arr2=str.match(/(<SPAN lang=EN-US><FONT face=\"Times New Roman\">(\w+))/gi);
var result='';
for(var i=0;i<arr.length;i++)
{
result+=('<img '+arr[i]+'>\n');
result+=arr2[i].replace('<SPAN lang=EN-US><FONT face=\"Times New Roman\">',"");
} alert(result);
}
谢谢!