本文整理汇总了C++中Matcher::group方法的典型用法代码示例。如果您正苦于以下问题:C++ Matcher::group方法的具体用法?C++ Matcher::group怎么用?C++ Matcher::group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matcher
的用法示例。
在下文中一共展示了Matcher::group方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readPapers
void readPapers(int papers, Scanner scanIn) {
int paper;
for (paper = 1; paper <= papers; paper++) {
String paperAuthors;
paperAuthors = scanIn.nextLine();
#ifdef DEBUG
printf("paper #%d %s\n", paper, paperAuthors);
#endif
Author authors[] = new Author[Author.MAX_PAPER_AUTHORS];
int authorsIndex = 0;
Pattern p = Pattern.compile("\\s*(\\S*)[,]\\s*(\\S*)[,:]");
Matcher m = p.matcher(paperAuthors);
while (m.find()) {
String lname = m.group(1);
String fname = m.group(2);
if (debug) {
printf("\t'%s' => '%s', '%s'\n", paperAuthors, lname, fname);
}
authors[authorsIndex] = Author.find(fname, lname);
if (authors[authorsIndex] == null) {
if (lname.length() == 0 || fname.length() == 0) {
continue;
}
authors[authorsIndex] = new Author(fname, lname);
}
authorsIndex++;
}
for (int i = 0; i < authorsIndex; i++) {
for (int j = 0; j < authorsIndex; j++) {
authors[i].publicouCom(authors[j]);
}
}
}
}
示例2: readCases
int readCases(int names, Scanner *scanIn, Collection<Entry<String, Author>> *theMap,
Set<Author> *targets) {
int nameInd;
for (nameInd = 1; nameInd <= names; nameInd++) {
String bigname;
bigname = scanIn.nextLine();
#ifdef DEBUG
printf("\tname #%d %s\n", nameInd, bigname);
#endif
Pattern p = Pattern.compile("\\s*(\\S*)[,]\\s*(\\S*)");
Matcher m = p.matcher(bigname);
if (m.find()) {
String lname = m.group(1);
String fname = m.group(2);
#ifdef DEBUG
printf("\tmatcher2'%s' => '%s', '%s'\n", bigname, lname, fname);
#endif
Author a = Author.find(fname, lname);response
theMap.add(new MyEntry(bigname, a));
if (a != null) {
targets.add(a);
#ifdef DEBUG
printf("\tauthor case '%s' is #%d\n", a.lname, targets.size());
#endif
}
} else {
theMap.add(new Entry<String, Author>(bigname, null));
}
}
return nameInd;
}