Regular expressions的小问题--英语好的进来!!谢谢

Maqic Maqic 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Regular expressions are one of the most broadly applicable specialized languages, a compact and expressive notation for describing patterns of text. Regular expressions are algorithmically interesting, easy to implement in their simpler forms, and very useful.
A regular expression is a sequence of characters that defines a pattern. Most characters in the pattern simply match themselves in a target string, so the regular expression "abc" matches that sequence of three letters wherever it occurs in the target. A few characters are used in patterns as metacharacters to indicate repetition, grouping, or positioning. In POSIX regular expressions, "^" stands for the beginning of a string and "$" for the end, so "^x" matches an "x" only at the beginning of a string, "x$" matches an "x" only at the end, "^x$" matches "x" only if it is the sole character of the string, and "^$" matches the empty string. The character "." (a period) matches any character, so "x.y" matches "xay," "x2y," and so on, but not "xy" or "xyxy." The regular expression "^.$" matches a string that contains any single character.
Please implement a simple Regular Expression matching program which only supports the three metacharacters, "^", "$", and ".". The program receives two command line arguments: the first one is a target string (without whitespace), and the second one is a regular expression pattern (without whitespace). If the pattern matches the string, then it prints "hit", else prints "lost".
For example, your executed program is named as "reg_match.exe". When you run "reg_match.exe abcdefg ^abc", the program prints "hit". When you run "reg_match.exe abcdefg abc$", the program prints "lost".

问题补充:1.用纯C编写;
2.用比较初级的编写,最好别用指针~我还没学呢
3.编译环境:code blocks
4.最好写几个注释吧!谢谢了
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
Maqic
C语言 70,039 成员 243,237 内容