我希望有人可以协助使用符合以下条件的RegEx: -
但 NOT 匹配: -
我目前使用的RegEx: -
JSONArray jsonArray = new JSONArray(response);
// Here you are getting the program JSONArray
JSONArray jsonProgramArray = jsonArray.getJSONArray("program_name");
for (int i = 0; i < jsonProgramArray.length() - 1; i++) {
// Get the each Json Object from the Array
JSONObject jsonProgramObject = jsonProgramArray.getJSONObject(i);
String program_name = jsonProgramObject.getString("program_name")
}
匹配除“locality”和“suburb”
这些确切单词之外的所有内容答案 0 :(得分:1)
你可以试试这个:
'/^(?:locality|suburb)(?:(?:-|_)?name)?$/im'
示例代码:
<?php
$re = '/^(?:locality|suburb)(?:(?:-|_)?name)?$/im';
$str = 'locality
Locality
LocalityName
locality_name
locality-name
suburb
Suburb
SuburbName
suburb_name
suburb-name
locality_pid
locality_index
LocalityRef
street_locality_pid
street_suburb_pid
';
preg_match_all($re, $str, $matches);
// Print the entire match result
print_r($matches);
?>