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


Java Matcher.end方法代码示例

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


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

示例1: parseStandardFormat

import java.util.regex.Matcher; //导入方法依赖的package包/类
private static Duration parseStandardFormat(boolean isNegative, String source)
{
    Matcher matcher = STANDARD_PATTERN.matcher(source);
    if (!matcher.find())
        throw invalidRequest("Unable to convert '%s' to a duration", source);

    Builder builder = new Builder(isNegative);
    boolean done = false;

    do
    {
        long number = groupAsLong(matcher, 1);
        String symbol = matcher.group(2);
        add(builder, number, symbol);
        done = matcher.end() == source.length();
    }
    while (matcher.find());

    if (!done)
        throw invalidRequest("Unable to convert '%s' to a duration", source);

    return builder.build();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:24,代码来源:Duration.java

示例2: tokenize

import java.util.regex.Matcher; //导入方法依赖的package包/类
public List<Tokenization> tokenize(List<String> sentences) {
	List<Tokenization> tokenizations = new ArrayList<>();
	int accumulatedSentenceLength = 0;
	for (String sentence : sentences) {
		int index = 0;
		Matcher matcher = pattern.matcher(sentence);
		List<Token> tokens = new ArrayList<>();
		while (matcher.find()) {
			String text = matcher.group();
			int from = matcher.start();
			int to = matcher.end();
			tokens.add(new Token(index, from, to, text));
			index++;
		}
		Tokenization tokenization = new Tokenization(tokens, sentence, accumulatedSentenceLength);
		tokenizations.add(tokenization);
		accumulatedSentenceLength += sentence.length();
		// System.out.println(tokenization.originalSentence);
		// System.out.println(
		// tokenization.tokens.stream().reduce("", (s, t) -> s + " " +
		// t.getText(), (s, tt) -> s + tt));
	}
	return tokenizations;
}
 
开发者ID:ag-sc,项目名称:JLink,代码行数:25,代码来源:SimpleRegexTokenizer.java

示例3: classifyGaps

import java.util.regex.Matcher; //导入方法依赖的package包/类
public List<AlignmentGap> classifyGaps() {
	// insertion interfered the position calculation of codons,
	// this's the offset variable so we can shift them back
	int codonOffset = 0;
	List<AlignmentGap> gaps = new ArrayList<AlignmentGap>();
	String dashesRegex = "(\\-+)";
	Pattern dashes = Pattern.compile(dashesRegex);
	Matcher matchedDashes = dashes.matcher(controlLine);
	while (matchedDashes.find()) {
		int gapStart = matchedDashes.start();
		int gapEnd = matchedDashes.end();
		if (IsInsertion(gapStart)) {
			gaps.addAll(findGapsBetween(
				gapStart, gapEnd, AlignmentGapType.FRAME_SHIFT_INSERTION,
				AlignmentGapType.INSERTION, codonOffset, true));
			codonOffset -= gapEnd - gapStart;
		}
		else {
			gaps.addAll(findGapsBetween(
				gapStart, gapEnd, AlignmentGapType.FRAME_SHIFT_DELETION,
				AlignmentGapType.DELETION, codonOffset, false));
		}
	}
	return gaps;
}
 
开发者ID:hivdb,项目名称:sierra,代码行数:26,代码来源:GapClassifier.java

示例4: setActionFromFormByIndex

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Searches content for form tag with given text and extracts the <code>action</code> attribute.<br/>
 * This method is useful where the FORM tags has empty body or there is only 1 FORM tag in the content.
 * <p>
 * <b>Content:</b><br/>
 * <code>...<br/>&lt;form action="http://blabla1/" &gt;hahahaha&lt;form><br />
 * &lt;form action="http://blabla2/" &gt;hahahaha&lt;form><br/>...<br/></code>
 * <br /><b>Using:</b>
 * <code><br />setActionFromFormByIndex(1)</code> - an action <code>http://blabla1/</code> will be extracted<br/>
 * <i>also this is possible:</i>
 * <code><br />setActionFromFormByIndex(2)</code> - an action <code>http://blabla2/</code> will be extracted<br/>
 * </p>
 * <p>All <code>&amp;amp;</code> entity is replaced to <code>&</code> by default.</p>
 *
 * @param index             index of the form tag in the content - the lowest index has number 1
 * @param useFormParameters if true then it extracts all input parameters from the <code>form</code> tag
 * @return builder instance
 * @throws cz.vity.freerapid.plugins.exceptions.BuildMethodException
 *          when no such FORM with text in the tag was found
 */
public MethodBuilder setActionFromFormByIndex(final int index, final boolean useFormParameters) throws BuildMethodException {
    if (index < 1)
        throw new IllegalArgumentException("Index must be higher or equal to 1");
    final Matcher formMatcher = getFormMatcher();
    int start = 0;
    int count = 1;
    boolean found = false;
    while (formMatcher.find(start)) {
        if (count++ == index) {
            found = true;
            inputForm(useFormParameters, formMatcher.group(FORM_MATCHER_TITLE_GROUP), formMatcher.group(FORM_MATCHER_FORM_CONTENT));
            break;
        }
        start = formMatcher.end();
    }
    if (!found) {
        throw new BuildMethodException("<Form> with index " + index + " from the top was not found");
    }
    return this;
}
 
开发者ID:jhkst,项目名称:dlface,代码行数:41,代码来源:MethodBuilder.java

示例5: matchMention

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static Spannable matchMention(Spannable spannable) {
    String text = spannable.toString();

    Pattern pattern = Pattern.compile(MATCH_MENTION);
    Matcher matcher = pattern.matcher(text);

    while (matcher.find()) {
        String str = matcher.group();
        int matcherStart = matcher.start();
        int matcherEnd = matcher.end();
        spannable.setSpan(new RichEditText.TagSpan(str), matcherStart, matcherEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        log("matchMention:" + str + " " + matcherStart + " " + matcherEnd);
    }

    return spannable;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:17,代码来源:RichEditText.java

示例6: search

import java.util.regex.Matcher; //导入方法依赖的package包/类
private Result search(int start, String pattern, String text, boolean canHandleCarriageReturn) {
	if (!canHandleCarriageReturn) {
		text = Tools.transformAllLineSeparators(text);
	}
	if (regExp.isSelected()) {
		Matcher matcher = Pattern.compile(pattern, caseSensitive.isSelected() ? 0 : Pattern.CASE_INSENSITIVE)
				.matcher(text.subSequence(start, text.length()));
		if (matcher.find()) {
			return new Result(start + matcher.start(), start + matcher.end());
		} else {
			return null;
		}
	} else {
		if (!caseSensitive.isSelected()) {
			text = text.toLowerCase();
			pattern = pattern.toLowerCase();
		}
		int result = text.indexOf(pattern, start);
		if (result == -1) {
			return null;
		} else {
			return new Result(result, result + pattern.length());
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:26,代码来源:SearchDialog.java

示例7: highLight

import java.util.regex.Matcher; //导入方法依赖的package包/类
private static String highLight(String s, Pattern pattern) {
    Matcher matcher = pattern.matcher(s);
    int idx = 0;
    StringBuilder sb = new StringBuilder();
    while (matcher.find(idx)) {
        int start = matcher.start();
        int end = matcher.end();
        if (start == end) {
            break;
        }
        sb.append(s.substring(idx, start));
        sb.append("<font bgcolor=\"FFB442\" color=\"black\">");
        sb.append(s.substring(start, end));
        sb.append("</font>");
        idx = matcher.end();
    }
    if(sb.length() > 0) {
        sb.append(idx < s.length() ? s.substring(idx, s.length()) : "");
        s = sb.toString();
    }
    return s;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:QueryTableCellRenderer.java

示例8: parse

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static void parse(Pattern pattern, String src, Consumer<Either<String, Matcher>> consumer) {
	Matcher matcher = pattern.matcher(src);
	int lastEnd=0;
	while (matcher.find()) {
		consumer.accept(Either.left(src.substring(lastEnd,matcher.start())));
		consumer.accept(Either.right(matcher));
		lastEnd=matcher.end();
	}
	consumer.accept(Either.left(src.substring(lastEnd)));
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:11,代码来源:Patterns.java

示例9: getNextByRegex

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Get the next token by a regex.
 *
 * @param pattern The regex pattern.
 * @return A regex token, contains the matcher.
 */
public RegexToken getNextByRegex(Pattern pattern) {
    if (!matchesRegex(pattern)) {
        throw new IllegalArgumentException("Next \"Regex Match\" not found!");
    }

    Matcher matcher = pattern.matcher(remain);
    final int end = cursor + matcher.end();
    RegexToken token = new RegexToken(matcher.group(), cursor + matcher.start(), end, matcher);
    jumpTo(cursor + end);
    return token;
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:18,代码来源:MessageProcessor.java

示例10: matchWhiteSpaceDelimnatedWords

import java.util.regex.Matcher; //导入方法依赖的package包/类
public void matchWhiteSpaceDelimnatedWords(CharBuffer cb, WordListener wl) {
    Matcher m = SPACE_PATTERN.matcher(cb);
    int i = 0;
    int s = 0;
    while(m.find()) {
        s = m.start();
        if (s != i) {
            wl.word(i, s);
        }
        i = m.end();
    }
    if (i != cb.length())
        wl.word(i, cb.length());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:BuiltInEncodingAlgorithm.java

示例11: SimpleTextFormat

import java.util.regex.Matcher; //导入方法依赖的package包/类
public SimpleTextFormat(@Nonnull final String format, @Nonnull final Pattern variablePattern) {
    this.format = format;

    final Matcher matcher = variablePattern.matcher(format);

    int pos = 0;
    tokens = new ArrayList<>();
    while (matcher.find(pos)) {
        int start = matcher.start();
        if (start > pos) {
            tokens.add(new TextToken(format.substring(pos, start)));
        }

        final String name = matcher.group(1);
        final Token stdAttr = STD_ATTRS.get(name);
        if (stdAttr != null) {
            tokens.add(stdAttr);
        } else {
            tokens.add(new AttributeToken(name));
        }

        pos = matcher.end();
    }

    if (pos < format.length()) {
        tokens.add(new TextToken(format.substring(pos)));
    }

    tokens.trimToSize();
}
 
开发者ID:ivnik,项目名称:smartlog,代码行数:31,代码来源:SimpleTextFormat.java

示例12: getHighLightKeyWord

import java.util.regex.Matcher; //导入方法依赖的package包/类
/** 
    * @param color 关键字颜色 
    * @param text 文本 
    * @param keyword 关键字 
    * @return 
    */  
   public static SpannableString getHighLightKeyWord(int color, String text, String keyword)
{  
       SpannableString s = new SpannableString(text);  
       Pattern p = Pattern.compile(keyword);  
       Matcher m = p.matcher(s);  
       while (m.find())
	{  
           int start = m.start();  
           int end = m.end();  
           s.setSpan(new ForegroundColorSpan(color), start, end,  
				  Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  
       }  
       return s;  
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:21,代码来源:HighLightKeyWordUtil.java

示例13: Highlighter

import java.util.regex.Matcher; //导入方法依赖的package包/类
public Highlighter(String text) {

			String stripped = STRIPPER.matcher(text).replaceAll("");
			mask = new boolean[stripped.length()];

			Matcher m = HIGHLIGHTER.matcher(stripped);

			int pos = 0;
			int lastMatch = 0;

			while (m.find()) {
				pos += (m.start() - lastMatch);
				int groupLen = m.group(1).length();
				for (int i = pos; i < pos + groupLen; i++) {
					mask[i] = true;
				}
				pos += groupLen;
				lastMatch = m.end();
			}

			m.reset(text);
			StringBuffer sb = new StringBuffer();
			while (m.find()) {
				m.appendReplacement(sb, m.group(1));
			}
			m.appendTail(sb);

			this.text = sb.toString();
		}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:30,代码来源:Window.java

示例14: deleteLeftWord

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Deletes all characters up to the leftmost whitespace from the cursor (including the whitespace).
 * If something is selected then delete the selection.
 * TODO: maybe expensive?
 */
@Override
public boolean deleteLeftWord() {
    mInputConnection.beginBatchEdit();
    // If something is selected then delete the selection and return
    if (mInputConnection.getSelectedText(0) != null) {
        mInputConnection.commitText("", 0);
    } else {
        CharSequence beforeCursor = mInputConnection.getTextBeforeCursor(MAX_DELETABLE_CONTEXT, 0);
        if (beforeCursor != null) {
            int beforeCursorLength = beforeCursor.length();
            Matcher m = WHITESPACE_AND_TOKEN.matcher(beforeCursor);
            int lastIndex = 0;
            while (m.find()) {
                // If the cursor is immediately left from WHITESPACE_AND_TOKEN, then
                // delete the WHITESPACE_AND_TOKEN, otherwise delete whatever is in between.
                lastIndex = beforeCursorLength == m.end() ? m.start() : m.end();
            }
            if (lastIndex > 0) {
                mInputConnection.deleteSurroundingText(beforeCursorLength - lastIndex, 0);
            } else if (beforeCursorLength < MAX_DELETABLE_CONTEXT) {
                mInputConnection.deleteSurroundingText(beforeCursorLength, 0);
            }
        }
    }
    mInputConnection.endBatchEdit();
    return true;
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:33,代码来源:InputConnectionCommandEditor.java

示例15: highlight

import java.util.regex.Matcher; //导入方法依赖的package包/类
private void highlight(Component comp, boolean cancel) {
    if (comp == bar) {
        return;
    }
    if (comp instanceof JTextPane) {
        JTextPane tcomp = (JTextPane)comp;
        if(!tcomp.isVisible()) {
            return;
        }
        String txt = tcomp.getText();
        Matcher matcher = pattern.matcher(txt);
        Highlighter highlighter = tcomp.getHighlighter();
        if (cancel) {
            highlighter.removeAllHighlights();
        } else {
            int idx = 0;
            while (matcher.find(idx)) {
                int start = matcher.start();
                int end = matcher.end();
                if (start == end) {
                    break;
                }
                try {
                    highlighter.addHighlight(start, end, highlighterAll);
                } catch (BadLocationException blex) {
                    BugtrackingManager.LOG.log(Level.INFO, blex.getMessage(), blex);
                }
                idx = matcher.end();
            }
        }
    } else if (comp instanceof Container) {
        Container cont = (Container)comp;
        for (Component subComp : cont.getComponents()) {
            highlight(subComp, cancel);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:FindSupport.java


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