日期:2014-05-16  浏览次数:20404 次

求一个简单的正则表达式
<P> <FONT   size=2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
<SPAN   id=SYS_1   contentEditable=false   unselectable= "on "   type= "SYSTEM "> 25   Apr   07 </SPAN>
<P> <FONT   size=2> Re:   Appointment   –  
<SPAN   id=OT_2   contentEditable=false   unselectable= "on "   type= "TERMS "> Senior   Accountant </SPAN>
<SPAN   id=OT_1   contentEditable=false   unselectable= "on "   type= "TERMS "> 1   Feb   2008 </SPAN>
</FONT> </P>   <P> <FONT   size=2> 2.&nbsp;   Probationary   Period   <BR> &nbsp;&nbsp;&nbsp;&nbsp;  

求从上面一段字符串中选出 <SPAN   id=OT_1   contentEditable=false   unselectable= "on "   type= "TERMS "> 1   Feb   2008 </SPAN>     整个字符串是一行。

------解决方案--------------------
<SPAN id=OT_1[\s|\S]*? <\/SPAN>
------解决方案--------------------
<textarea id=textarea1>
<P> <FONT size=2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN id=SYS_1 contentEditable=false unselectable= "on " type= "SYSTEM "> 25 Apr 07 </SPAN>
<P> <FONT size=2> Re: Appointment –
<SPAN id=OT_2 contentEditable=false unselectable= "on " type= "TERMS "> Senior Accountant </SPAN>
<SPAN id=OT_1 contentEditable=false unselectable= "on " type= "TERMS "> 1 Feb 2008 </SPAN>
</FONT> </P> <P> <FONT size=2> 2.&nbsp; Probationary Period <BR> &nbsp;&nbsp;&nbsp;&nbsp;
</script>
</head>


</textarea>

<script>
alert(aaa(textarea1.value))
function aaa(x)
{
var rtn= " ";
var arr = x.match(/ <span\s*id=OT_1.*> (.*?) <\/span> /ig);
for(i=0;i <arr.length;i++)
{
rtn += arr[i] + "\n ";
}
return(rtn);
}
</script>