當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。