Package org.rstudio.core.client.regex

Examples of org.rstudio.core.client.regex.Match


         text(data, className);
         return;
      }

      int tail = 0;
      Match match = CONTROL.match(data, 0);
      while (match != null)
      {
         int pos = match.getIndex();

         // If we passed over any plain text on the way to this control
         // character, add it.
         text(data.substring(tail, pos), className);

         tail = pos + 1;

         switch (data.charAt(pos))
         {
            case '\r':
               carriageReturn();
               break;
            case '\b':
               backspace();
               break;
            case '\n':
               newline();
               break;
            case '\f':
               formfeed();
               break;
            default:
               assert false : "Unknown control char, please check regex";
               text(data.charAt(pos) + "", className);
               break;
         }

         match = match.nextMatch();
      }

      // If there was any plain text after the last control character, add it
      text(data.substring(tail), className);
   }
View Full Code Here


      return result ;
   }
  
   private String peek(String regex)
   {
      Match match = Pattern.create(regex).match(data_, pos_) ;
      if (match == null)
         return null ;
      int idx = match.getIndex() ;
      if (idx != pos_)
         return null ;
     
      return match.getValue() ;
   }
View Full Code Here

   }
  
   private String eatUntil(String regex, boolean eatAllOnFailure)
   {
      int start = pos_ ;
      Match match = Pattern.create(regex).match(data_, pos_) ;
      if (match == null)
      {
         if (eatAllOnFailure)
         {
            pos_ = data_.length() ;
            return data_.substring(start) ;
         }
         else
         {
            return null ;
         }
      }
      else
      {
         pos_ = match.getIndex() ;
         return data_.substring(start, pos_) ;
      }
   }
View Full Code Here

      if (dirPath.startsWith("/"))
         results.add(FileSystemItem.createDir("/"));

      Pattern pattern = Pattern.create("[^/]+");
      Match m = pattern.match(dirPath, 0);
      while (m != null)
      {
         results.add(FileSystemItem.createDir(
               dirPath.substring(0, m.getIndex() + m.getValue().length())));

         m = m.nextMatch();
      }

      return results.toArray(new FileSystemItem[0]);
   }
View Full Code Here

            return RES.iconPublicFolder();
         else
            return RES.iconFolder();
      }

      Match m = EXT_PATTERN.match(getName(), 0);
      if (m == null)
         return RES.iconText();

      String lowerExt = m.getValue().toLowerCase();
      if (lowerExt.equals(".csv"))
      {
         return RES.iconCsv();
      }
      else if (lowerExt.equals(".pdf"))
View Full Code Here

               public String next()
               {
                  if (pos >= text.length())
                     return null;

                  Match match = newline.match(text, pos);
                  String result;
                  if (match == null)
                  {
                     result = text.substring(pos);
                     pos = text.length();
                  }
                  else
                  {
                     result = text.substring(pos, match.getIndex());
                     pos = match.getIndex() + match.getValue().length();
                  }
                  return result;
               }

               @Override
View Full Code Here

                  continue;
               }
            case Node.TEXT_NODE:
               String text = ((Text)node).getData();

               Match lastMatch = null;
               Match match = NEWLINE.match(text, 0);
               while (match != null && linesLeft > 0)
               {
                  lastMatch = match;
                  linesLeft--;
                  match = match.nextMatch();
               }

               if (linesLeft > 0 || lastMatch == null)
               {
                  node = removeAndGetNext(node);
View Full Code Here

      if (!pre)
         return 0;
      String value = textNode.getData();
      Pattern pattern = Pattern.create("\\n");
      int count = 0;
      Match m = pattern.match(value, 0);
      while (m != null)
      {
         count++;
         m = m.nextMatch();
      }
      return count;
   }
View Full Code Here

      Document doc = el.getOwnerDocument();

      Pattern pattern = Pattern.create("\\n");
      int tail = 0;
      Match match = pattern.match(plainText, 0);
      while (match != null)
      {
         if (tail != match.getIndex())
         {
            String line = plainText.substring(tail, match.getIndex());
            el.appendChild(doc.createTextNode(line));
         }
         el.appendChild(doc.createBRElement());
         tail = match.getIndex() + 1;
         match = match.nextMatch();
      }

      if (tail < plainText.length())
         el.appendChild(doc.createTextNode(plainText.substring(tail)));
   }
View Full Code Here

   {
      if (requestData_.equals("[REDACTED]"))
         return requestData_;

      Pattern p = Pattern.create("\\\"method\\\":\\s*\\\"([^\"]+)\\\"");
      Match match = p.match(requestData_, 0);
      if (match == null)
         return null;
      return match.getGroup(1);
   }
View Full Code Here

TOP

Related Classes of org.rstudio.core.client.regex.Match

Copyright © 2018 www.massapicom. 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.