正则表达式在一些字符串和_之后检查国家/地区代码

时间:2018-10-23 16:05:23

标签: java regex

我必须使用正则表达式检查字符串license_<Two digit country code>的国家代码_

例如license_uslicense_ca

1 个答案:

答案 0 :(得分:0)

此代码获取select user_id ,recommended_ids[0] as col_1 ,recommended_ids[1] as col_2 ,recommended_ids[2] as col_3 ,recommended_ids[3] as col_4 ,recommended_ids[4] as col_5 from my_table where size(recommended_ids) >= 5 --to filter for array lengths >= 5 之后的剩余字符串:

_

打印

String key="license_us";
String country = key.substring(key.indexOf("_") + 1);
System.out.println(country);

那你为什么需要正则表达式?