java 中的匹配器值

The Matcher-value in java

我想获取标签内的值

txt4="<script type='text/javascript'>eval(function(p,a,c,k,e,d){while(c--)if(k[c])p=p.replace(new RegExp('\b'+c.toString(a)+'\b','g'),k[c]);return p}('2("44").43({42:[{k:\'b\',o:"15://5.39.1f.1e:41/40/1c:1b/1a/3z?h=1d"},{k:\'b\',o:"7://5.39.1f.1e:3y/1d/v.1c"}],3x:"7://3w.9.4/3v/26/1b/1a/3u.3t",3s:"3r",3q:"19%",3p:"19%",3o:"3n",3m:"14",3l:"3k",3j:{"7://9.4/3i/3h.3g":{}},3f:[],3e:{3d:\'#3c\',3b:16,3a:"38",37:0},"36":{35:"%34 33%18%32%31%30%2z.4%2y-b.2x%22 2w%p 2v%p 2u%p 2t%2s 2r%18%2q%22 2p%2o 2n%2m%17%2l%2k%17",13:"7://9.4/b"},15:{2j:5},2i:\'2h\',2g:\'2f 6.0\',2e:\'7://9.4\',2d:{o:\'7://9.4/2c-2b.2a\',r:14,13:\'7://9.4/\',29:12}});n f,m;n e=0;n a=0;2().28(3(x){a=-1});2().27(3(x){8(a>0)e+=x.11-a;a=x.11;8(0!=0&&e>=0){a=-1;2().25();2().24(23);$(\'#21\').l();$(\'d.i\').l()}8(5>0&&e>=5&&m!=1){m=1;$(\'d.20\').1z(\'1y\')}});2().1x(3(x){s(x)});2().1w(3(){$(\'d.i\').l()});2().1v(3(){8(10)10()});3 t(){g 2().c()?(2().c().z?2().c().z:\'\'):\'\'};3 u(){g 2().c()?2().c().k:\'\'};3 q(w,j){8(1u y==\'3\')y(\'1t\',\'1s\',w,u(),t()+(j?\' \'+j:\'\'))};3 s(x){$(\'d.i\').r();8(f)g;f=1;$.1r(\'7://9.4/1q?1p=1o&1n=b&1m=1l-1k-0-1j-1i\');8(2().1h()==0)q(\'1g\')}',36,149,'||jwplayer|function|to|||http|if|streamplay|p0182151|rouf2x9y2fkv|getPlaylistItem|div|tt182151|vvplay|return||video_ad|extra|description|show|vvad|var|file|3D0|sendGa|hide|doPlay|getMediaId|getDesc||category||ga|mediaid|isPlayerReady|position||link|true|rtmp||3E|3D|100|00299|01|mp4|m4oho5kspqikkfn2may72osnfzmn3gutwzqctblzqy6rygwzxbrozgbfmy|113|70|Play|getPosition|0085d1d86bd2532b44fb49d7924a4a14|1455038408|148|182151|hash|file_code|view|op|dl|get|event|send|typeof|onReady|onComplete|onPlay|slow|fadeIn|video_ad_fadein|play_limit_box||false|setFullscreen|stop||onTime|onSeek|margin|png|48x48|favicon|logo|aboutlink|StreamPlay|abouttext|uniform|stretching|bufferlength|2FIFRAME|3C|3D538|HEIGHT|3D954|WIDTH|22true|allowfullscreen|3DNO|SCROLLING|MARGINHEIGHT|MARGINWIDTH|FRAMEBORDER|html|2Fembed|2Fstreamplay|2F|3A|22http|SRC|3CIFRAME|code|sharing|backgroundOpacity|Arial||fontFamily|fontSize|dacf84|color|captions|tracks|js|lightsout|player6|plugins|start|startparam|androidhls|flash|primary|height|width|1470|duration|jpg|n2zjvi0sf0i4|scap|img|image|8777|n2zjvi0sf0i4_n|vod|19350|sources|setup|vplayer'.split('|')))
</script>";


Matcher matcher = Pattern.compile("<script type='text/javascript'>not be to do</script>").matcher(txt4);
    ArrayList<String> codejava = new ArrayList<String>(); 
    while (matcher.find()) {
        codejava.add(matcher.group(1));
    }

如果我理解正确,您正试图在 <script type='text/javascript'> </script> 标签之间获取 'text'。 我是 RegEx 菜鸟,所以我想出了这个解决方案:

String  s = "<script type='text/javascript'></script>";
        String inTags = s.substring(s.indexOf("<script type='text/javascript'>")+31,s.indexOf("</script>"));

它使用字符串 class 中的方法创建一个子字符串,该子字符串从 <script type='text/javascript'> 的末尾开始并在 </script>

的开头结束

我没有测试过这段代码的效率,我不知道那是不是你想要的,但这是我从你的主要推论得出的post。