List of usage examples for java.util.regex Pattern MULTILINE
int MULTILINE
To view the source code for java.util.regex Pattern MULTILINE.
Click Source Link
From source file:com.processing.core.PApplet.java
static Pattern matchPattern(String regexp) { Pattern p = null;//from ww w . j a v a 2 s .c o m if (matchPatterns == null) { matchPatterns = new HashMap<String, Pattern>(); } else { p = matchPatterns.get(regexp); } if (p == null) { if (matchPatterns.size() == 10) { // Just clear out the match patterns here if more than 10 are being // used. It's not terribly efficient, but changes that you have >10 // different match patterns are very slim, unless you're doing // something really tricky (like custom match() methods), in which // case match() won't be efficient anyway. (And you should just be // using your own Java code.) The alternative is using a queue here, // but that's a silly amount of work for negligible benefit. matchPatterns.clear(); } p = Pattern.compile(regexp, Pattern.MULTILINE | Pattern.DOTALL); matchPatterns.put(regexp, p); } return p; }
From source file:com.xpn.xwiki.doc.XWikiDocument.java
/** * @return the sections in the current document *//* w w w . j a va 2 s .c om*/ private List<DocumentSection> getSections10() { // Pattern to match the title. Matches only level 1 and level 2 headings. Pattern headingPattern = Pattern.compile("^[ \\t]*+(1(\\.1){0,1}+)[ \\t]++(.++)$", Pattern.MULTILINE); Matcher matcher = headingPattern.matcher(getContent()); List<DocumentSection> splitSections = new ArrayList<DocumentSection>(); int sectionNumber = 0; // find title to split while (matcher.find()) { ++sectionNumber; String sectionLevel = matcher.group(1); String sectionTitle = matcher.group(3); int sectionIndex = matcher.start(); // Initialize a documentSection object. DocumentSection docSection = new DocumentSection(sectionNumber, sectionIndex, sectionLevel, sectionTitle); // Add the document section to list. splitSections.add(docSection); } return splitSections; }
From source file:carnero.cgeo.original.libs.Base.java
public String getMapUserToken(Handler noTokenHandler) { final Response response = request(false, "www.geocaching.com", "/map/default.aspx", "GET", "", 0, false); final String data = response.getData(); String usertoken = null;//from w w w . j ava2 s. c o m if (data != null && data.length() > 0) { final Pattern pattern = Pattern.compile("var userToken[^=]*=[^']*'([^']+)';", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); final Matcher matcher = pattern.matcher(data); while (matcher.find()) { if (matcher.groupCount() > 0) { usertoken = matcher.group(1); } } } if (noTokenHandler != null && (usertoken == null || usertoken.length() == 0)) { noTokenHandler.sendEmptyMessage(0); } return usertoken; }
From source file:carnero.cgeo.cgBase.java
public String getMapUserToken(Handler noTokenHandler) { final cgResponse response = request(false, "www.geocaching.com", "/map/default.aspx", "GET", "", 0, false); final String data = response.getData(); String usertoken = null;/*ww w.jav a 2s.co m*/ if (data != null && data.length() > 0) { final Pattern pattern = Pattern.compile("var userToken[^=]*=[^']*'([^']+)';", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); final Matcher matcher = pattern.matcher(data); while (matcher.find()) { if (matcher.groupCount() > 0) { usertoken = matcher.group(1); } } } if (noTokenHandler != null && (usertoken == null || usertoken.length() == 0)) { noTokenHandler.sendEmptyMessage(0); } return usertoken; }