7 ответов
+ 5
Hassanah ,
we appreciate your support, but it is not seen as a helpful behavior if we post ready-made codes as long as the op has not posted his attempt.
in this situation it is better to give hints.
+ 5
Daniel C ,
we can avoid splitting the string, if we use *word boundary* instead of *string boundary*:
"\ba\w+e\b"
+ 3
If you need regex, you should still split the string at each space. Then, you can test with the following regular expression:
^a.*e$
That expression means to check for a starting letter 'a', then any amount of any character, ending with 'e'.
(tested at https://regexr.com/ )
+ 3
import regex
wordsWithAAndE = regex.findall(r'\b[a]\w+[e]\b', inp, regex.I)
print(wordsWithAAndE)
not sure if this is what you're looking for, but I tried to find a solution to your problem, hope it helps :)
+ 2
We won't do your homework for you, but I'll outline how this program should work to guide you in the right direction.
Once you get the input, split it at every space character (the string.split method). This will return a list of each word.
For each entry in the list, check if the first letter is 'a' and if the last letter is 'e'. In Python, the first index is accessed using [0] and the last index is accessed using [-1].
+ 2
Lothar,
Ok I'll be mindful next time :)
0
Daniel C I want it using regex