android 正则表达式截取字符串问题

weixin_36528687 weixin_36528687 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
textView = findViewById( R.id.textview );
editText = findViewById( R.id.edittext );

button1 = findViewById( R.id.button );
button1.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {

String str = textView.getText().toString();
String regEx = "--sector:\\s*?(\\d+),\\s*block:\\s*\\d+,\\s*key\\s*type:[A-Z],\\s*key\\s*count:\\s*\\d+\\s*Found";
Pattern pattern = Pattern.compile( regEx );
Matcher matcher = pattern.matcher( str );
boolean s = matcher.matches();
int i = (s==true?1:0);
//System.out.print( s );

String str2 = textView.getText().toString();
String regEx2 = "type:([AB]),\\\\s*key\\\\s*count:\\\\s*\\\\d+\\\\s*Found";
Pattern pattern2 = Pattern.compile( regEx2 );
Matcher matcher2 = pattern2.matcher( str2 );
boolean b = matcher2.matches();
int o = (b==true?1:0);



textView.setText("No key specified, trying default keys \n" +
"--sector:13, block: 55, key type:B, key count:13 \n" +
"Found valid key:[ffffffffffff] \n" +
"--sector:14, block: 59, key type:B, key count:13 \n" +
"Found valid key:[ffffffffffff] \n" +
"--sector:15, block: 63, key type:B, key count:13 \n" +
"Found valid key:[ffffffffffff] \n" +
"Found keys have been transferred to the emulator memory \n");

if(-1!= (textView.getText().toString().indexOf("Found keys have been transferred to the emulator memory")))
{
((SectorandKey) getApplication()).setI(textView.getText().toString());
((SectorandKey) getApplication()).setO(textView.getText().toString());

editText.setText("hf mf nested 1 ".toCharArray(),i,o);
}
}


} );

}
}
我是这样写的 为什么正则表达式没有截取到值呢 求大神解答一下 感谢啦
...全文
评论 8
收藏 已收藏
分享
返回顶部
weixin_36528687
Android 80,490 成员 91,371 内容