[英]I want to compare the user input from my form to the queried data. but I want it not to be case sensitive. how do I do that?
/* compares the values of txtOrigin and txtDestination to the query variables assuming it matches / / * 假设txtOrigin和txtDestination的值与查询变量匹配,则将其与 /
if((origin.getText().toString().matches(queryOrigin))
&& (destination.getText().toString().matches(queryDestination)))
{
//proceed to route found layout
Intent openRouteFound = new Intent("com.icommute.feu.RouteFound");
startActivity(openRouteFound);
}
/**compares the values of txtOrigin
and txtDestination to the query
variables assuming it doesn't match*/
else
{
//proceed to no routes found layout
Intent openNoRoute = new Intent("com.icommute.feu.NoRoute");
startActivity(openNoRoute);
}
Please try that: 请尝试:
if((origin.getText().toString().equalsIgnoreCase(queryOrigin))
&& (destination.getText().toString().equalsIgnoreCase(queryDestination)))
{
...
}
use .equalsIgnoreCase() method eg: 使用.equalsIgnoreCase()方法,例如:
if((origin.getText().toString().equalsIgnoreCase(queryOrigin))
&& (destination.getText().toString().equalsIgnoreCase(queryDestination)))
{
} }
Try this 尝试这个
origin.getText().toString().matches("(?i)" + queryOrigin)
. origin.getText().toString().matches("(?i)" + queryOrigin)
。
This will make regex CASE_INSENSITIVE
这将使正则表达式为CASE_INSENSITIVE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.