本帖最后由 wua0550 于 2016-11-28 19:00 编辑 <REC><OR_N>161128102230</OR_N><TIME>2016-11-28 16:00:58</TIME><STA>1</STA><TYPE>2</TYPE><CO_I>200022</CO_I><PRI>53.58</PRI><QTY>10.00</QTY><BAL>10.00</BAL><WD_T></WD_T></REC><REC><OR_N>161128102150</OR_N><TIME>2016-11-28 16:00:22</TIME><STA>5</STA><TYPE>2</TYPE><CO_I>200022</CO_I><PRI>53.69</PRI><QTY>10.00</QTY><BAL>10.00</BAL><WD_T>2016-11-28 16:00:47</WD_T></REC><REC><OR_N>161128102146</OR_N><TIME>2016-11-28 16:00:20</TIME><STA>5</STA><TYPE>1</TYPE><CO_I>200016</CO_I><PRI>166.03</PRI><QTY>3.00</QTY><BAL>3.00</BAL><WD_T>2016-11-28 16:00:47</WD_T></REC><REC><OR_N>161128102173</OR_N><TIME>2016-11-28 16:00:34</TIME><STA>1</STA><TYPE>2</TYPE><CO_I>100010</CO_I><PRI>21.48</PRI><QTY>5.00</QTY><BAL>5.00</BAL><WD_T></WD_T></REC>
原文本如上,我想取两个<REC></REC>之间<STA>1</STA> 为1的条目
理想的输出应该为<OR_N>161128102230</OR_N><TIME>2016-11-28 16:00:58</TIME><STA>1</STA><TYPE>2</TYPE><CO_I>200022</CO_I><PRI>53.58</PRI><QTY>10.00</QTY><BAL>10.00</BAL><WD_T></WD_T></REC>
<REC><OR_N>161128102173</OR_N><TIME>2016-11-28 16:00:34</TIME><STA>1</STA><TYPE>2</TYPE><CO_I>100010</CO_I><PRI>21.48</PRI><QTY>5.00</QTY><BAL>5.00</BAL><WD_T></WD_T></REC>
<REC>.*?<STA>1</STA>.*?</REC> 我用这条正则式去取的时候会向后匹配到第二,第三个REC内的sta 1 的内容~~所以失败了~
我只想用一条正则解决,如果告诉我别的方法的~~先谢谢了~~不过我不想用! |