Package org.rstudio.core.client.regex

Examples of org.rstudio.core.client.regex.Pattern.match()


    */
   private String removeHost(String url)
   {
      String pageUrl = Document.get().getURL();
      Pattern p = Pattern.create("^http(s?)://[^/]+");
      Match m = p.match(pageUrl, 0);
      if (m == null)
      {
         assert false : "Couldn't parse page URL: " + url;
         return url;
      }
View Full Code Here


      ArrayList<Match> sectionMatches = new ArrayList<Match>();

      int pos = 0;
      int lastHeaderStart = -1;
      Match m;
      while (null != (m = sectionHeaderPattern.match(data, pos)))
      {
         sectionMatches.add(m);

         if (lastHeaderStart >= 0)
            sectionData.add(data.substring(lastHeaderStart, m.getIndex()));
View Full Code Here

            if (filePair == null)
            {
               // Although "Index: <filename>" appeared, no diff was actually
               // generated (e.g. binary file)
               Pattern hrule = Pattern.create("^=+$");
               Match m = hrule.match(section.data, 0);
               int startAt = (m != null) ? m.getIndex() + m.getValue().length()
                                         : 0;
               Iterable<String> lines = StringUtil.getLineIterator(
                     StringUtil.trimBlankLines(section.data.substring(startAt)));
               DiffChunk chunk = createInfoChunk(lines);
View Full Code Here

      int curRow = getSession().getSelection().getCursor().getRow();
      while (++curRow < getSession().getLength())
      {
         String line = getSession().getLine(curRow);
         Pattern pattern = Pattern.create("[^\\s]");
         Match match = pattern.match(line, 0);
         if (skipBlankLines && match == null)
            continue;
         int col =  (match != null) ? match.getIndex() : 0;
         getSession().getSelection().moveCursorTo(curRow, col, false);
         getSession().unfold(curRow, true);
View Full Code Here

   }

   private String extractIndentation(String code)
   {
      Pattern leadingWhitespace = Pattern.create("^(\\s*)");
      Match match = leadingWhitespace.match(code, 0);
      return match == null ? "" : match.getGroup(1);
   }

   private boolean isSelectionValueEmpty(String selection)
   {
View Full Code Here

   {
      String code = docDisplay_.getCode(selection);
      String[] lines = code.split("\n");
      String prefix = StringUtil.getCommonPrefix(lines, true);
      Pattern pattern = Pattern.create("^\\s*" + commentPrefix + "+('?)\\s*");
      Match match = pattern.match(prefix, 0);
      // Selection includes non-comments? Abort.
      if (match == null)
         return;
      prefix = match.getValue();
      final boolean roxygen = match.hasGroup(1);
View Full Code Here

      if (searchString.length() == 0)
         return;

      Pattern pattern = createPattern();
      String line = editor_.getCurrentLine();
      Match m = pattern.match(line,
                              editor_.getSelectionStart().getColumn());
      if (m != null
          && m.getIndex() == editor_.getSelectionStart().getColumn()
          && m.getValue().length() == editor_.getSelectionValue().length())
      {
View Full Code Here

      {
         Pattern pattern = createPattern();
         StringBuilder result = new StringBuilder();

         int pos = 0; // pointer into original string
         for (Match m = pattern.match(code, 0);
              m != null;
              m = m.nextMatch())
         {
            occurrences++;
View Full Code Here

      Pattern pattern = docDisplay_.getFileType().getRnwStartPatternBegin();
      if (pattern == null)
         return -1;

      String linePart = line.substring(0, cursorPos);
      Match match = pattern.match(linePart, 0);
      if (match == null)
         return -1;

      // See if the cursor is already past the end of the chunk header,
      // for example <<foo>>=[CURSOR].
View Full Code Here

         return -1;

      // See if the cursor is already past the end of the chunk header,
      // for example <<foo>>=[CURSOR].
      Pattern patternEnd = docDisplay_.getFileType().getRnwStartPatternEnd();
      if (patternEnd != null && patternEnd.match(linePart, 0) != null)
         return -1;

      return match.getValue().length();
   }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.