android 正则表达式截取字符串问题
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);
}
}
} );
}
} 我是这样写的 为什么正则表达式没有截取到值呢 求大神解答一下 感谢啦
...全文
相关推荐
截取字符串 省略用...表现 grivdview截取数据用..表现出来
截取字符串 省略用...表现 grivdview截取数据用..表现出来
Android中EditText禁止输入表情的实例代码
本篇文章主要介绍了Android中EditText禁止输入表情的实例代码,具有一定的参考价值,有兴趣的可以了解一下
Android 手机号自动分割
Android手机号自动分割,是在网上看到的
JAVA 字符串应用笔记
本文档是Xingyu在Android软件开发过程中的随手笔记,主要对字符串的一些常规用法作了随手记录,以备后忘,没什么技术含量, 对初学者有一定参考作用,高手就不要下了。
android 封装抓取网页信息的实例代码
android 封装抓取网页信息的实例代码,需要的朋友可以参考一下


