Re.split() in Python | HackerRank Solution

Hello coders, today we are going to solve Re.split() HackerRank Solution in Python.

Re.split() in Python

Task

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 preceeded and followed by a digit.

Sample Input 0

100,000,000.000

Sample Output 0

100
000
000
000

Solution – Re.split() in Python

regex_pattern = r'[.,]+'    # Do not delete 'r'.

import re
print("\n".join(re.split(regex_pattern, input())))

Disclaimer: The above Problem (Re.split()) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

Leave a Comment

Your email address will not be published. Required fields are marked *