If the match succeeds then more information can be obtained via the start, end, and group methods.
7172737475767778798081
s = Pattern.compile("ed2k:\\/\\/\\|server\\|([0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+)\\|([0-65535]*)\\|\\/"); m = s.matcher(link); return m.matches(); } public static List<ED2KServerLink> extractLinks(String rawData) { Pattern s = Pattern.compile("ed2k:\\/\\/\\|server\\|([0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+)\\|([0-65535]*)\\|\\/");
99100101102103104105106107108109
Pattern s; Matcher m; s = Pattern.compile(ED2K_LINK_PATTERN, Pattern.CASE_INSENSITIVE); m = s.matcher(fileLink); if (m.matches()) { this.fileName=m.group(1); this.fileSize=Long.valueOf(m.group(2)).longValue(); this.fileHash = new FileHash(m.group(3)); this.partHashSet = extractPartHashes(fileHash,m.group(4)); this.rootHash = m.group(5);
181182183184185186187188189190191
for (Iterator i = uncountables.iterator(); i.hasNext();) { Pattern pattern = (Pattern)i.next(); Matcher matcher = pattern.matcher(str); if (matcher.matches()) { return str; } }
194195196197198199200201202203204
{ Inflection inflection = (Inflection)i.next(); Pattern pattern = inflection.getPattern(); String replace = inflection.getReplace(); Matcher matcher = pattern.matcher(str); if (matcher.matches()) { return matcher.replaceFirst(replace); } } return str.replaceFirst("([\\w]+)([^s])$", "$1$2s");
138139140141142143144145146147148
public static boolean isValidLink(String link) { Pattern s; Matcher m; s = Pattern.compile(ED2K_LINK_PATTERN, Pattern.CASE_INSENSITIVE); m = s.matcher(link); return m.matches(); } public String getAsString() { StringBuilder sb = new StringBuilder(); sb.append("ed2k://|file|"+fileName+"|"+fileSize+"|"+fileHash+"|"); // base
6768697071727374
*/ public static boolean isConstraintKind(String expression, String kind) { Pattern pattern = Pattern.compile(".*\\s*" + StringUtils.trimToEmpty(kind) + "\\s*\\w*\\s*:.*", Pattern.DOTALL); Matcher matcher = pattern.matcher(StringUtils.trimToEmpty(expression)); return matcher.matches(); } }
7374757677787980818283
//Pattern p = Pattern.compile("/(eta_[0-9]*)/$"); // doesn't match Pattern p = Pattern.compile(".*/(eta_[0-9]*)/$"); // matches Matcher m = p.matcher("fred/the/eta_211/"); //boolean b = m.matches(); if ( m.matches()) { System.out.println( "Matches" ); System.out.println( "numGroups : " + m.groupCount()); for ( int i = 0; i <= m.groupCount(); i++) {
107108109110111112113114115116117
while (true) { line = raf.readLine(); if (line == null) break; if (line.trim().length() == 0) continue; Matcher matcher = p.matcher(line); return matcher.matches(); } return false; } @Override
263264265266267268269270271272273
if (line == null) return null; if (line.startsWith("#")) continue; if (line.trim().length() == 0) continue; //System.out.printf("line %s%n", line); matcher = vinfo.p.matcher(line); if (matcher.matches()) { String stnid = matcher.group(stn_fldno).trim(); if (stnid.equals(stationId)) break; } } recno++;
272273274275276277278279280281282
* @param name test this. * @return true if valid name. */ static public boolean isValidNetcdf3ObjectName(String name) { Matcher m = objectNamePattern.matcher(name); return m.matches(); } /** * Valid Netcdf Object name as a regular expression. * @return regular expression pattern describing valid Netcdf Object names.