Regular expressions的小问题--英语好的进来!!谢谢
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.最好写几个注释吧!谢谢了
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.最好写几个注释吧!谢谢了
...全文
相关推荐
Mastering Regular Expressions(3rd) 无水印pdf
"《Mastering Regular Expressions》第三版是Jeffrey E. F. Friedl撰写的一本权威IT书籍,专注于正则表达式的深入学习和实践。这本书是编程和文本处理领域的经
Mastering_Regular_Expressions
#### 四、《Mastering Regular Expressions》的内容概览本书共分为七个章节和两个附录,涵盖了正则表达式的各个方面:1.
Java 9 Regular Expressions 无水印pdf
Java 9 Regular Expressions 是一本深入讲解 Java 9 版本中正则表达式特性的技术书籍。该PDF版本由 Anubhava Srivastava 所著,由 Packt Pub
Mastering Python Regular Expressions 无水印pdf
"Mastering Python Regular Expressions 无水印pdf"《Mastering Python Regular Expressions》是一本专为深入理解和高效使用P
Mastering Regular Expressions(3rd Edition)
正则表达式(Regular Expressions,简称regex或regexp)是一种模式匹配工具,广泛应用于文本处理、数据验证、搜索和替换等场景。


