首页 > 编程知识 正文

java表示负数,matchparent和wrap

时间:2023-05-05 00:09:57 阅读:137365 作者:2613

虽然我刚用了Android,但是我奉命支援实习项目。

我可以说有以下详细信息。

Fonia Taylo

产品管理器

foniataylo@gmail.com

98706886

根据以上详细内容,我想传递给类,可以使用正则表达式过滤电子邮件地址,然后只将过滤后的电子邮件地址传递给EditText。

我搜索了很多关于正则表达式的教程。 特别是关于Android Pattern和Matcher类的教程。

但是,我发现的所有例子都是用于只验证在EditText字段中输入的文本。

我必须做的是

如上所示,验证整个文本

使用正则表达式过滤电子邮件地址,然后删除剩下的文本

只把这个电子邮件地址交给EditText

现在,以下是我的课:

publicclassregexocr 1扩展活动{

private Pattern pattern;

私有匹配器;

private String recognizedText,textToUse;

privatestaticfinalstringemail _ pattern=

' ^ [ _ a-za-z0-9- ] ((.([ _ a-za-z0-9-] * @ ) ) )。

“[a-za-Z0-9-]((.[a-za-Z0-9] ) ) ().[a-za-Z]{2,} ) ) $ );

@Override

保护性视频创建(bundlesavedinstancestate )。

//todo自动生成方法stub

super.oncreate (savedinstancestate;

setcontentview (r.layout.activity _ create contact;

//gettingthepathoftheimagefromanotherclass

Bundle extras=this.getIntent ().getExtras );

recognized text=extras.getstring (' text );

text to use=记录的text;

}

@Override

公共配置变更(configurationnewconfig ) {

super.onconfigurationchanged (new config );

setcontentview (r.layout.use text );

showText (;

//log.I(tag,' onConfigChanged ' );

}

private void showText ()

//log.I(tag,' ShowText ' );

intentintent=newintent(this,CreateContactActivityOCR.class;

开始活动(intent;

}

公共电子邮件验证器

pattern pattern=pattern.com pile (email _ pattern );

matcher matcher=pattern.matcher (text to use );

if(Matcher.find ) )

{

string email=text to use.substring (matcher.start )、matcher.end );

} else {

//todohandleconditionwheninputdoesn ' thaveanemailaddress

}

}

publicbooleanvalidate (finalstringhex ) {

matcher=pattern.matcher(hex );

return matcher.matches (;

}

}

正如您所看到的,几乎是不完整的。我想把" textToUse "交给正则表达式验证,继续上述功能。

编辑:

通过以下方法:

公共电子邮件验证器

pattern pattern=pattern.com pile (email _ pattern );

matcher matcher=pattern.matcher (text to use );

if(Matcher.find ) )

{

string email=text to use.substring (matcher.start )、matcher.end );

} else {

//todohandleconditionwheninputdoesn ' thaveanemailaddress

}

}

提取邮件地址; 然后,如何故意将提取的电子邮件地址传递到其他类的EditText中?

如果有什么想法的话,请告诉我代码的更改方法。 谢谢你。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。