Redian新闻
>
请教github上1道编程题的题意
avatar
请教github上1道编程题的题意# JobHunting - 待字闺中
M*A
1
请教各位朋友, 下面github上1道编程题的题意。
Write a program in C/C++ that translates a pattern specification
provided as ancommand line argument into a regular expression, processes
lines of input text receivedfrom stdin using that regular expression to
qualify matches, and finally writes eachmatching input line to stdout.
Each line of input is terminated by the newline character'n', and the
program should terminate when it receives EOF.The program should be
executable as follows:$ cat input.txt | program "is this message %{0}
ballpark %{1S3}" > output.txtThe program should be structured to parse the
pattern specification and generated aregular expression which
expresses the pattern. The program should then use thelibpcre library (www.
pcre.org) available on linux and Windows systems, to executematches to
qualify each line of text received on stdin.
https://github.com/dmi3s/ptfilter/blob/master/README
这道题需要实现将1个文本文件input.txt逐行扫描,把含有特定字符串的行读到output
.txt。
如果是写1个函数来实现特定字符串的匹配,应该可以办到。
不过好像题意是,要调用 http://www.pcre.org/ 中的libpcre library的函数来实现特定字符串的匹配, 而不是自己写1个函数来实现特定字符串的匹配。
可是 The PCRE library is a set of functions that implement regular
expression pattern matching using the same syntax and semantics as Perl 5.
请教各位朋友,是不是需要建立C/C++ call Perl 的API。
万分感谢。
avatar
s*e
2
C++有自己的regex库。libpcre可以用LoadLibrary(win)或者dl_open(linux)打开。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。