Extract String From Text 1.0

Posted rms365

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Extract String From Text 1.0相关的知识,希望对你有一定的参考价值。

 main.cpp

 1 #include <iostream>
 2 #include <stdlib.h>
 3 #include <fstream>
 4 #include <string>
 5 
 6 using namespace std;
 7 
 8 string readLine ( const char* filepath ) {
 9     ifstream file;
10     file.open ( filepath );
11     string text;
12     if ( file.is_open() ) {
13         while ( !file.eof() ) {
14             getline ( file, text );
15             break;
16         }
17     }
18     file.close();
19     return text;
20 }
21 
22 int main ( int argc, char* argv[] ) {
23     string opt = argv[1];
24     if ( !opt.compare ( "-p" ) ) {
25         string text = readLine ( argv[3] );
26         size_t found = text.find ( argv[2] );
27         if ( found != string::npos ) {
28             cout << found << endl;
29             return 0;
30         }
31     } else if ( !opt.compare ( "-e" ) ) {
32         string text = readLine ( argv[4] );
33         cout << text.substr ( atoi ( argv[2] ), atoi ( argv[3] ) ) << endl;
34         return 0;
35     }
36     return -1;
37 }

技术图片

附件1

以上是关于Extract String From Text 1.0的主要内容,如果未能解决你的问题,请参考以下文章

EXTRACT(type FROM date)

Extract Chorus From Audio 1.0

JPA 标准 - 如何使用 EXTRACT(字段 FROM 时间戳)?

csharp extract_from_mysql_connection_string

Extract URL from HAR 1.0

BigQuery REGEXP_EXTRACT from URL - 提取参数值