当前位置: 首页>>代码示例>>Java>>正文


Java Matcher.matches方法代码示例

本文整理汇总了Java中java.util.regex.Matcher.matches方法的典型用法代码示例。如果您正苦于以下问题:Java Matcher.matches方法的具体用法?Java Matcher.matches怎么用?Java Matcher.matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.regex.Matcher的用法示例。


在下文中一共展示了Matcher.matches方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: marathon_select

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override public boolean marathon_select(String tab) {
    Matcher matcher = CLOSE_PATTERN.matcher(tab);
    boolean isCloseTab = matcher.matches();
    tab = isCloseTab ? matcher.group(1) : tab;
    TabPane tp = (TabPane) node;
    ObservableList<Tab> tabs = tp.getTabs();
    for (int index = 0; index < tabs.size(); index++) {
        String current = getTextForTab(tp, tabs.get(index));
        if (tab.equals(current)) {
            if (isCloseTab) {
                ((TabPaneSkin) tp.getSkin()).getBehavior().closeTab(tabs.get(index));
                return true;
            }
            tp.getSelectionModel().select(index);
            return true;
        }
    }
    return false;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaFXTabPaneElement.java

示例2: isPhoneNumberValid

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 判断电话号码是否有效
 *
 * @param phoneNumber
 * @return true 有效 / false 无效
 */
public static boolean isPhoneNumberValid(String phoneNumber) {

    boolean isValid = false;

    String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
    CharSequence inputStr = phoneNumber;

    Pattern pattern = Pattern.compile(expression);
    Matcher matcher = pattern.matcher(inputStr);

    if (matcher.matches()) {
        isValid = true;
    }
    return isValid;
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:22,代码来源:CommonUtils.java

示例3: parse

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static GeoPoint parse(String str) {
    String description;
    Matcher m = WITH_DESCRIPTION_PATTERN.matcher(str);
    if (m.matches()) {
        description = m.group(1).trim();
        str = m.group(2).trim();
    } else {
        description = null;
    }

    String[] parts = str.split(",");
    if (parts.length < 2) {
        throw new MemgraphException("Too few parts to GeoPoint string. Expected at least 2 found " + parts.length + " for string: " + str);
    }
    if (parts.length >= 4) {
        throw new MemgraphException("Too many parts to GeoPoint string. Expected less than or equal to 3 found " + parts.length + " for string: " + str);
    }
    double latitude = parsePart(parts[0]);
    double longitude = parsePart(parts[1]);
    Double altitude = null;
    if (parts.length >= 3) {
        altitude = Double.parseDouble(parts[2]);
    }
    return new GeoPoint(latitude, longitude, altitude, description);
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:26,代码来源:GeoPoint.java

示例4: apply

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
boolean apply(IXulDataSelectContext dataCtx, ArrayList<XulDataNode> ctx) {
	if (_pattern == null) {
		for (int i = ctx.size() - 1; i >= 0; i--) {
			if (!_content.equals(ctx.get(i).getValue())) {
				ctx.remove(i);
			}
		}
	} else {
		for (int i = ctx.size() - 1; i >= 0; i--) {
			Matcher matcher = _pattern.matcher(ctx.get(i).getValue());
			if (matcher == null || !matcher.matches()) {
				ctx.remove(i);
			}
		}
	}
	return true;
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:19,代码来源:XulBindingSelector.java

示例5: isHKPhoneLegal

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 香港手机号码8位数,5|6|8|9开头+7位任意数
 */
public static boolean isHKPhoneLegal(String str) throws PatternSyntaxException {
    String regExp = "^(5|6|8|9)\\d{7}$";
    Pattern p = Pattern.compile(regExp);
    Matcher m = p.matcher(str);
    return m.matches();
}
 
开发者ID:CodeDogDream,项目名称:CampusHelp,代码行数:10,代码来源:PhoneFormatCheckUtils.java

示例6: match

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static boolean match(String text, String regex) {
    Pattern p = Pattern.compile(regex);
    Matcher matcher = p.matcher(text);
    if (matcher.matches()) {
        return true;
    }
    return false;
}
 
开发者ID:JackWHLiu,项目名称:jackknife,代码行数:9,代码来源:TextUtils.java

示例7: getGID

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public String getGID(URL url) throws MalformedURLException {
    Pattern p = Pattern.compile("^https?://(www\\.)?zizki\\.com/([a-zA-Z0-9\\-_]+).*$");
    Matcher m = p.matcher(url.toExternalForm());
    if (!m.matches()) {
        throw new MalformedURLException("Expected URL format: http://www.zizki.com/author/albumname, got: " + url);
    }
    return m.group(m.groupCount());
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:10,代码来源:ZizkiRipper.java

示例8: getGraphPathWithVersion

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String getGraphPathWithVersion() {
    Matcher matcher = versionPattern.matcher(this.graphPath);
    if (matcher.matches()) {
        return this.graphPath;
    }
    return String.format("%s/%s", this.version, this.graphPath);
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:8,代码来源:GraphRequest.java

示例9: canRip

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public boolean canRip(URL url) {
    String url_name = url.toExternalForm();
    if (explicit_domains_1.contains(url_name.split("/")[2])) {
        Pattern pa = Pattern.compile("(?:https?://)?(?:www\\.)?[a-z1-9-]*\\.[a-z1-9]*/album/([a-zA-Z1-9]*)/?$");
        Matcher ma = pa.matcher(url.toExternalForm());
        if (ma.matches()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:13,代码来源:CheveretoRipper.java

示例10: isTextValid

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static boolean isTextValid(String aText, boolean canBeNull){
	if (!canBeNull && (aText == null || aText.trim().length() == 0)){
		return(false);
	}
	
	if (canBeNull && (aText == null || aText.trim().length() == 0)){
		return(true);
	}
	
	String checkText = aText.toUpperCase();
   	try { 
   		Pattern pattern = Pattern.compile(patternStr, Pattern.DOTALL + Pattern.CASE_INSENSITIVE + Pattern.UNIX_LINES);
    	Matcher matcher = pattern.matcher(checkText);
    	if (matcher.matches()) {
	        return(false);
    	}
   		Pattern patternHex = Pattern.compile(hexPatternStr, Pattern.DOTALL + Pattern.CASE_INSENSITIVE + Pattern.UNIX_LINES);
    	Matcher matcherHex = patternHex.matcher(checkText);
    	if (matcherHex.matches()) {
	        return(false);
    	}
   	}
   	catch (Exception e) {
		Debug.info("Threw exception " + e.getMessage());
        return(false);
   	}

	
	return(true);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:31,代码来源:WebTextValidation.java

示例11: upsLength

import java.util.regex.Matcher; //导入方法依赖的package包/类
private static int upsLength(String path) {
  Matcher m = goUpPattern.matcher(path);
  if(m.matches()) {
    return m.group(1).length();
  } else {
    return 0;
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:9,代码来源:PersistenceManager.java

示例12: getGID

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public String getGID(URL url) throws MalformedURLException {
    Pattern p = Pattern.compile("^https?://[wm.]*dribbble\\.com/([a-zA-Z0-9]+).*$");
    Matcher m = p.matcher(url.toExternalForm());
    if (m.matches()) {
        return m.group(1);
    }
    throw new MalformedURLException("Expected dribbble.com URL format: " +
            "dribbble.com/albumid - got " + url + "instead");
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:11,代码来源:DribbbleRipper.java

示例13: isEmail

import java.util.regex.Matcher; //导入方法依赖的package包/类
public boolean isEmail(String email) {
	String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
	Pattern p = Pattern.compile(str);
	Matcher m = p.matcher(email);

	return m.matches();
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:8,代码来源:RegisterActivity.java

示例14: getDarkHighlightColor

import java.util.regex.Matcher; //导入方法依赖的package包/类
@ColorInt
public static int getDarkHighlightColor(String className) {

    Matcher matcher = HIGHLIGHT_CLASS_PATTERN.matcher(className);
    int classNumber = 0;
    if (matcher.matches()) {
        classNumber = Integer.parseInt(matcher.group(1));
    }

    return highlightDarkColorMap.get(classNumber);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:12,代码来源:Highlight.java

示例15: getFrequencyFromString

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Converts the frequency string to a double value.
 *
 * @param freq
 * @return
 */
private double getFrequencyFromString(String freq)
{
    double f = 1.0;

    if (freq == null || freq.length() == 0) {
        return 1.0;
    }

    Matcher matcher = frequencyPattern.matcher(freq);
    if (matcher.matches()) {
        String fractionalPart = matcher.group(2);
        if (fractionalPart == null || fractionalPart.length() == 0) {
            fractionalPart = "0";
        }

        f =
            Double.parseDouble(matcher.group(1)) + Double.parseDouble(fractionalPart)
                / Math.pow(10, fractionalPart.length());
        f /= 100.0;
    } else {
        matcher = frequencyFractionPattern.matcher(freq);
        if (matcher.matches()) {
            f = Double.parseDouble(matcher.group(1)) / Double.parseDouble(matcher.group(2));
        } else {
            if (freq.equalsIgnoreCase("very rare")) {
                f = 0.01;
            } else if (freq.equalsIgnoreCase("rare")) {
                f = 0.05;
            } else if (freq.equalsIgnoreCase("occasional")) {
                f = 0.075;
            } else if (freq.equalsIgnoreCase("frequent")) {
                f = 0.33;
            } else if (freq.equalsIgnoreCase("typical")) {
                f = 0.50;
            } else if (freq.equalsIgnoreCase("common")) {
                f = 0.75;
            } else if (freq.equalsIgnoreCase("hallmark")) {
                f = 0.90;
            } else if (freq.equalsIgnoreCase("obligate")) {
                f = 1;
            } else {
                logger.info("Unknown frequency identifier: {}", freq);
            }
        }
    }
    return f;
}
 
开发者ID:johntiger1,项目名称:boqa,代码行数:54,代码来源:BOQA.java


注:本文中的java.util.regex.Matcher.matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。