本文整理汇总了C++中Matcher::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Matcher::find方法的具体用法?C++ Matcher::find怎么用?C++ Matcher::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matcher
的用法示例。
在下文中一共展示了Matcher::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: find
void find(string text, string pattern, int expect) {
Matcher * impl = getImpl(pattern);
clock_t start_time = clock();
int pos = impl->find(text);
clock_t end_time = clock();
printf("pos :%d\texpect : %d\n", pos, expect);
assert(pos == expect);
// cout << pattern.size() << endl;
string out_text = (text.size() <= 100) ? text : "Too Long";
string out_pattern =(pattern.size() <= 100) ? pattern : "Too Long";
printf("start time : %lu\n", start_time);
printf("end time : %lu\n", end_time);
printf("text : %s\npattern : %s\nmatch positon : %d\nexecution time: %lfs\n\n",
out_text.c_str(), out_pattern.c_str() , pos, ((double) end_time - start_time) / CLOCKS_PER_SEC);
delete impl;
}
示例3: 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;
}