Regular expressions的小问题--英语好的进来!!谢谢
Maqic 2010-12-05 11:12:24 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.最好写几个注释吧!谢谢了