A little weird green frog speaks in a very strange variation of English: it reverses sentence, omitting all puntuation marks  `, ; ( ) - ` except the final exclamation, question or period. We urgently need help with building a proper translator.
To simplify the task, we always use lower-case letters. Apostrophes are forbidden as well.

Translator should be able to process multiple sentences in one go. Sentences are separated by arbitrary amount of spaces.

**Examples**

`you should use python.` -> `python use should you.`

`look, a fly!` -> `fly a look!`

`multisentence is good. is not it?` -> `good is multisentence. it not is?`

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def frogify(s):
	

Solutions:
import re

def frogify(s):
	return ' '.join((' '.join(re.findall('[a-z]+', sentence)[::-1]) + punct for (sentence, punct) in re.findall('(.*?)([.!?])', s)))


import re

def frogify(s):
	delimiters = set(['.', '!', '?'])
	sentences = re.split('([\\!\\.\\?])', re.sub('[,\\;\\)\\(-]', '', s))
	res = []
	sentence = ''
	for item in sentences:
		if item in delimiters:
			res.append(' '.join(sentence.split(' ')[::-1]) + item)
			sentence = ''
		elif item:
			sentence += re.sub('\\s+', ' ', item).strip()
	return ' '.join(res)


import re

def rev(s):
	(s, punc) = (s[:-1], s[-1])
	return ' '.join((word for word in s.split()[::-1])) + punc

def frogify(s):
	return ' '.join((rev(sentence).strip() for sentence in re.findall('.+?[.?!]', re.sub('[^ a-z.!?]', '', s))))


import re

def reverse_sentence(m):
	words = m.group(1).split()
	rev = ' '.join(reversed(words))
	return m.expand(' {}\\2'.format(rev))

def frogify(s):
	s = re.sub('[,;{}\\-\\(\\)]', '', s)
	return re.sub('(.*?)([.!?])', reverse_sentence, s).strip()


frogify = lambda s, r=__import__('re').sub: r('\\w.*?(?=[.?!])', lambda m: ' '.join(m.group().split()[::-1]), ' '.join(r("[(),;'-]", '', s).split()))


def frogify(s):
	for c in '.!?':
		if c in s:
			return f'{c} '.join(map(frogify, s.split(c))).strip()
	words = ''.join((c for c in s.lower() if c == ' ' or 'a' <= c <= 'z')).split()
	return ' '.join(words[::-1])


import re

def frogify(s):
	print(s)
	s = re.sub('\\s?[(),\\[\\];{}-]+', '', s)
	print(s)
	match = re.findall('\\w[\\w, -]+', s)
	for i in match:
		print(i)
		rev = ' '.join(reversed(i.split()))
		s = re.sub(i, rev, s)
	return s.lstrip()


import re

def frogify(s):
	a = re.split('([!?.])', s.translate(str.maketrans('', '', ',;()-')).strip())
	if not a[-1]:
		a.pop()
	return ''.join((f(x) for x in a))

def f(s):
	return s if s in '!?.' else ' ' * (s[0] == ' ') + ' '.join(s.strip().split()[::-1])


import re

def frogify(s):
	what = s.replace('.', '.&').replace('!', '!&').replace('?', '?&').replace(',', '').replace('-', '').replace('(', '').replace(')', '').replace(';', '')
	reason = re.sub(' +', ' ', what)
	reason = reason.split('&')
	hi = reason[:-1]
	arr = []
	for i in hi:
		end = i[-1:]
		result = i[:-1].split(' ')
		final = result[::-1]
		final2 = ' '.join(final)
		if final2[len(final2) - 1] == ' ':
			final2 = final2[:-1]
		if len(final2) > 0 and final2[0] == ' ':
			final2 = final2.lstrip()
		arr.append(final2 + end)
	sun = ' '.join(arr)
	return sun


import re

def frogify(s):
	t = re.split('(\\W+)', s)[:-1]
	if len(t) == 0:
		return ''
	t = [re.sub('[ ]*[,;:()-]', '', s) for s in t]
	t = [(s, ' ')[s == ''] for s in t]
	while t[0] == ' ':
		t.pop(0)
	matches = [j for (j, x) in enumerate(t) if x[0] in '.?!']
	oldi = 0
	for i in matches:
		t[oldi:i] = t[oldi:i][::-1]
		oldi = i + 1
	return ''.join(t)