Re.split() in python HackerRank Solution

Hello Programmers, In this post, you will know how to solve the Re.split() in python HackerRank solution. This problem is a part of the HackerRank Python Programming Series.

Ezoicreport this adRe.split() in python HackerRank solution
Re.split() in python HackerRank solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Re.split() in python Hacker rank solution

Ezoicreport this adProblem

re.split()
The re.split() expression splits the string by occurrence of a pattern.

>>> import re
>>> re.split(r"-","+91-011-2711-1111")
['+91', '011', '2711', '1111']

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 :

100,000,000.000

Sample Output :

100
000
000
000

Re.split() in python Hackerrank solutions

regex_pattern = r"[.,]+"	# Do not delete 'r'.
# Re.split() in python - hacker rank solution END
import re
print("\n".join(re.split(regex_pattern, input())))

Disclaimer: The above Problem (Re.split() in python) is generated by Hackerrank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: Detect Floating Point Number in Python HackerRank Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad