Given a pattern string and a test string, Your task is to implement RegEx substring matching. If the pattern is preceded by a ^, the pattern(excluding the ^) will be matched with the starting position of the text string. Similarly, if it is preceded by a $, the pattern(excluding the ^) will be matched with the ending position of the text string. If no such markers are present, it will be checked whether pattern is a substring of test.
^coal coaltar Result : 1 tar$ coaltar Result : 1 rat algorate Result: 1 abcd efgh Result :0
Input: The first line of input contains an integer T denoting the no of test cases . Then T test cases follow. Each test case contains two lines. The first line of each test case contains a pattern string. The second line of each test case consists of a text string.
Output: Corresponding to every test case, print 1 or 0 in a new line.
1<=length of the string<=1000
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.