Construct an algorithm[as comment lines] and write a python program to create a regular expression to retrieve all words starting with input1 or ending with input2 in each string.
For example:
Test Input
An apple for a day keeps the doctor away
a
y
Result
An
apple
a
away
day
away
Answers
Answered by
0
Answer:
\ Used to drop the special meaning of character following it
[] Represent a character class
^ Matches the beginning
$ Matches the end
. Matches any character except newline
| Means OR (Matches with any of the characters separated by it.
? Matches zero or one occurrence
* Any number of occurrences (including 0 occurrences)
+ One or more occurrences
{} Indicate the number of occurrences of a preceding regex to match.
() Enclose a group of Regex
Similar questions