当前位置: 首页>>代码示例>>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;未经允许,请勿转载。