當前位置: 首頁>>代碼示例>>Java>>正文


Java Matcher.hitEnd方法代碼示例

本文整理匯總了Java中java.util.regex.Matcher.hitEnd方法的典型用法代碼示例。如果您正苦於以下問題:Java Matcher.hitEnd方法的具體用法?Java Matcher.hitEnd怎麽用?Java Matcher.hitEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.regex.Matcher的用法示例。


在下文中一共展示了Matcher.hitEnd方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createEmbedding

import java.util.regex.Matcher; //導入方法依賴的package包/類
private Collection<Embedding> createEmbedding(Snapshot snapshot, int offset, int len) {
    Collection<Embedding> es = new ArrayList<>();
    CharSequence text = snapshot.getText().subSequence(offset, offset + len);
    Matcher matcher = GENERIC_MARK_PATTERN.matcher(text);
    int tmpOffset = 0;
    while(matcher.find()) {
        int start = matcher.start();
        int end = matcher.end();
        if(start != end) {
            //create embedding from the original
            es.add(snapshot.create(offset + tmpOffset, start - tmpOffset, JS_MIMETYPE));
            tmpOffset = end;
            if(!matcher.hitEnd()) {
                //follows the delimiter - @@@ - convert it to the GENERATED_JS_IDENTIFIER
                es.add(snapshot.create(GENERATED_JS_IDENTIFIER, JS_MIMETYPE));
            }
        }
    }
    es.add(snapshot.create(offset + tmpOffset, text.length() - tmpOffset, JS_MIMETYPE));
    return es;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:JsEmbeddingProvider.java

示例2: setTabCompleteName

import java.util.regex.Matcher; //導入方法依賴的package包/類
private void setTabCompleteName(UsernameTilePingFragment usernameTilePingFragment)
    {
//        Toast.makeText(getActivity(), usernameTilePingFragment.getmUsername(), Toast.LENGTH_SHORT).show();
        String name = usernameTilePingFragment.getmUsername();
        name = name.replace(" ", "");
        String currentText = mMessage.getText().toString();

        Pattern p = Pattern.compile("\\[email protected](.+?)\\b");
        Matcher m = p.matcher(currentText);

        while (!m.hitEnd())
        {
            if (m.find() && name.toLowerCase().contains(m.group().replace("@", "").toLowerCase()))
            {
                String before = currentText.substring(0, currentText.toLowerCase().lastIndexOf(m.group().toLowerCase()));
                String after = currentText.substring(currentText.toLowerCase().lastIndexOf(m.group().toLowerCase()) + m.group().length());
                String middle = "@" + name;

                mMessage.setText(before.concat(middle).concat(after));
                mMessage.setSelection(mMessage.getText().toString().length());
            }
        }
    }
 
開發者ID:HueToYou,項目名稱:ChatExchange-old,代碼行數:24,代碼來源:ChatFragment.java

示例3: compare

import java.util.regex.Matcher; //導入方法依賴的package包/類
public int compare(String s1, String s2) {
    int compareValue = 0;
    Matcher s1ChunkMatcher = alphaNumChunkPattern.matcher(s1);
    Matcher s2ChunkMatcher = alphaNumChunkPattern.matcher(s2);
    String s1ChunkValue = null;
    String s2ChunkValue = null;
    while (s1ChunkMatcher.find() && s2ChunkMatcher.find() && compareValue == 0) {
        s1ChunkValue = s1ChunkMatcher.group();
        s2ChunkValue = s2ChunkMatcher.group();
        try {
            // compare double values - ints get converted to doubles. Eg. 100 = 100.0
            Double s1Double = Double.valueOf(s1ChunkValue);
            Double s2Double = Double.valueOf(s2ChunkValue);
            compareValue = s1Double.compareTo(s2Double);
        } catch (NumberFormatException e) {
            // not a number, use string comparison.
            compareValue = s1ChunkValue.compareTo(s2ChunkValue);
        }
        // if they are equal thus far, but one has more left, it should come after the one that doesn't.
        if (compareValue == 0) {
            if (s1ChunkMatcher.hitEnd() && !s2ChunkMatcher.hitEnd()) {
                compareValue = -1;
            } else if (!s1ChunkMatcher.hitEnd() && s2ChunkMatcher.hitEnd()) {
                compareValue = 1;
            }
        }
    }
    return compareValue;
}
 
開發者ID:JetBrains,項目名稱:teamcity-google-agent,代碼行數:30,代碼來源:AlphaNumericStringComparator.java

示例4: HivePath

import java.util.regex.Matcher; //導入方法依賴的package包/類
public HivePath(final ObjectInspector oi, final String path) {
	this.oi = oi;
	this.accessors = new ArrayList<>();

	final Matcher m = STRUCT_ACCESS_PATTERN.matcher(path);

	while (m.usePattern(STRUCT_ACCESS_PATTERN).find()) {
		accessors.add(new StructAccessor(m.group("field")));
		m.region(m.end(), m.regionEnd());

		boolean match;
		do {
			match = false;
			if (m.usePattern(ARRAY_ACCESS_PATTERN).find()) {
				accessors.add(new ArrayAccessor(Integer.parseInt(m.group("index"))));
				m.region(m.end(), m.regionEnd());
				match = true;
			}
			if (m.usePattern(MAP_ACCESS_PATTERN).find()) {
				final String key;
				try {
					key = MAPPER.readValue(m.group("keyjson"), String.class);
				} catch (IOException e) {
					throw new IllegalArgumentException(e);
				}
				accessors.add(new MapAccessor(key));
				m.region(m.end(), m.regionEnd());
				match = true;
			}
		} while (match);
	}

	if (!m.hitEnd())
		throw new IllegalArgumentException("error at " + m.regionStart());
}
 
開發者ID:CyberAgent,項目名稱:hive-jq-udtf,代碼行數:36,代碼來源:HivePath.java


注:本文中的java.util.regex.Matcher.hitEnd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。