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.最好写几个注释吧!谢谢了
...全文
74 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Maqic 2010-12-05
  • 打赏
  • 举报
回复
大牛们,可以给个思路吗?
Maqic 2010-12-05
  • 打赏
  • 举报
回复
我知道,但是没思路啊!学c以来的第一个问题,昨天想了一晚上,没琢磨出来!哎
bdmh 2010-12-05
  • 打赏
  • 举报
回复
这是正则表达式

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧