[Home|Training|Problems|Contests|C Language] | [Login|Register] |
Problems Status Rank |
Problem 1031
Pattern Matching
Time Limit: 1000ms
Memory Limit: 65536kb Description
A regular expression is
a string which contains some normal characters and some meta
characters. The meta characters include
Input
Every two lines
of the input is a pattern-matching problem. The first line is a
regular expression, and the second line is the string to be
matched. Any line will be no more than 80 character. A line with
only an
"
end
"
will terminate the input.
Output
For each
matching problem, you should give an answer in one line. This
line contains the string to be matched, but the leftmost
substring that can match the regular expression should be
bracketed. If no substring matches the regular expression, print
the input string.
Sample Input
.* asdf f.*d. sefdfsde [0-9]+ asd345dsf [^\*-\*] **asdf**fasd b[a-z]*r[s-u]* abcdefghijklmnopqrstuvwxyz [T-F] dfkgjf end Sample Output
(asdf) se(fdfsde) asd(345)dsf **(a)sdf**fasd a(bcdefghijklmnopqrstu)vwxyz dfkgjf Hint
1. There may be some case like this : 1****,2+++++
2. There may be lines having more than 80 characters(but be sure less than 200)
3. You must check the end of file as the end of the datas. There will be no line with a single "end".:(
|