Given a string containing a list of integers separated by commas, write the function string_to_int_list(s) that takes said string and returns a new list containing all integers present in the string, preserving the order.

For example, give the string "-1,2,3,4,5", the function string_to_int_list() should return [-1,2,3,4,5]

Please note that there can be one or more consecutive commas whithout numbers, like so: "-1,-2,,,,,,3,4,5,,6"

Source: codewars | Difficulty: EASY
Tags: String algorithms

Starter code: def string_to_int_list(s):
	

Solutions:
def string_to_int_list(s):
	return [int(n) for n in s.split(',') if n]


def string_to_int_list(s):
	return [int(x) for x in s.split(',') if x != '']


import re
number_pattern = re.compile('-?[0-9]+')

def string_to_int_list(s):
	return [int(c) for c in s.split(',') if re.match(number_pattern, c)]


def string_to_int_list(s):
	return [int(nb) for nb in s.split(',') if nb]


def string_to_int_list(s):
	return [int(x) for x in s.split(',') if len(x) > 0]


def string_to_int_list(string):
	return [int(i) for i in string.split(',') if i.isdigit() or (i.startswith('-') and i[1:].isdigit())]


def string_to_int_list(s):

	def isint(j):
		try:
			int(j)
			return True
		except:
			return False
	return [int(i) for i in s.split(',') if isint(i)]