In this HackerRank Re.split() problem solution You are given a string S consisting only of digits 0-9, commas,, and dots. Your task is to complete the regex_pattern defined below, which will be used to re.split() all of the , and . symbols in S. It’s guaranteed that every comma and every dot in S is preceded and followed by a digit.

HackerRank Re.split() in python problem solution

HackerRank Re.split() in python problem solution

from __future__ import print_function
import sys, re

def resplit(text):
    return [ x for x in re.split(r'[,.]+', text) if len(x) > 0 ]

def main():
    for line in resplit(sys.stdin.read().rstrip()):
        print(line)

if __name__ == '__main__':
    main()