本文整理汇总了Java中com.google.gwt.regexp.shared.RegExp.test方法的典型用法代码示例。如果您正苦于以下问题:Java RegExp.test方法的具体用法?Java RegExp.test怎么用?Java RegExp.test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.regexp.shared.RegExp
的用法示例。
在下文中一共展示了RegExp.test方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadUrl
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
private boolean loadUrl(String fragmentOverride) {
// If the root doesn't match, no routes can match either.
if(!matchRoot()) return false;
String fragment = this.fragment = this.getFragment(fragmentOverride);
for (int i = 0; i < handlers.length(); i++) {
Properties handler = handlers.get(i);
RegExp route = handler.get("route");
Function callback = handler.getFunction("callback");
if (route.test(fragment)) {
callback.f(fragment);
return true;
}
}
return false;
}
示例2: getNumberOfMatches
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
/**
* Returns the number of matches found in a string by a regexp. If the regexp is not a global
* regexp this will return a maximum of 1. This does not setLastIndex(0) automatically, you must
* do it manually.
*
* @returns number of matches
*/
public static int getNumberOfMatches(RegExp regexp, String input) {
if (regexp == null || input == null || input.isEmpty()) {
return 0;
}
// if we don't check here we will loop forever
if (!regexp.getGlobal()) {
return regexp.test(input) ? 1 : 0;
}
int matches = 0;
for (MatchResult result = regexp.exec(input);
result != null && result.getGroup(0).length() != 0;
result = regexp.exec(input)) {
matches++;
}
return matches;
}
示例3: getFileTypeByNamePattern
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
@Override
public FileType getFileTypeByNamePattern(String name) {
if (!Strings.isNullOrEmpty(name)) {
for (FileType type : fileTypes) {
if (type.getNamePattern() != null) {
RegExp regExp = RegExp.compile(type.getNamePattern());
if (regExp.test(name)) {
return type;
}
}
}
}
return unknownFileType;
}
示例4: selectWordCounter
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
public static WordCounter selectWordCounter(String text) {
final RegExp rFull = RegExp.compile("[\\u3040-\\uA4CF]", "g");
final RegExp rLetter = RegExp.compile("[\\uAC00-\\uD7AF]", "g");
if (rFull.test(text)) {
return new FullWordCounter();
} else if (rLetter.test(text)) {
return new LetterWordCounter();
} else {
return new FastWordCounter();
}
}
示例5: validate
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
@Override
protected boolean validate() {
String pattern = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*"
+ "@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
RegExp regExp = RegExp.compile(pattern);
return userName.getValue().length() > 1 && authority.getValue() != null
&& regExp.test(email.getValue());
}
示例6: iOSversion
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
public static int iOSversion() {
int version = 0;
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
RegExp regExp = RegExp.compile("OS (\\d+)_(\\d+)_?(\\d+)?");
MatchResult matcher = regExp.exec(Window.Navigator.getAppVersion());
boolean matchFound = regExp.test(Window.Navigator.getAppVersion());
if (matchFound) {
version = Integer.parseInt(matcher.getGroup(1), 10); // Just get the
// major
// version.
}
return version;
}
示例7: removeAll
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
private static String removeAll(final RegExp exp,
final int group,
final String content) {
String result = content;
while (exp.test(result)) {
final MatchResult matchResult = exp.exec(result);
if (matchResult != null) {
String toReplace = matchResult.getGroup(group);
result = result.replace(toReplace,
"");
}
}
return result;
}
示例8: datasourceNameChanged
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
@Override
public void datasourceNameChanged(String name) {
wizard.getDataObject().setDatasourceId(name);
wizard.getContext().put(NewDatasourceWizard.DATASOURCE_NAME_KEY, name);
RegExp regExp = RegExp.compile("^\\S.*$");
if (regExp.test(name)) {
view.removeNameError();
} else {
view.showNameError();
}
updateButtonsState();
}
示例9: resetAndTest
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
/** Resets the RegExp lastIndex to 0 before testing. This is only useful for global RegExps. */
public static boolean resetAndTest(RegExp regexp, String input) {
regexp.setLastIndex(0);
return regexp.test(input);
}
示例10: isValidFileName
import com.google.gwt.regexp.shared.RegExp; //导入方法依赖的package包/类
public static boolean isValidFileName(String fn) {
RegExp re = RegExp.compile("^[^\\/:*?\"<>|]+$");
return re.test(fn);
}