I need to remove zeros that are in the middle of a string, while keeping the ones at the end (in pyspark). So far I have only found regex that remove leading or trailing zeros. Example:
df1 = spark.createDataFrame(
[
("GH0786",),
("HH7040",),
("IP0090",),
("AH567",),
],
["number"]
)
INPUT:
+-------+
|number |
+-------+
|GH0786 |
|HH7040 |
|IP0090 |
|AH567 |
+-------+
EXPECTED OUTPUT:
+-------+
|number |
+-------+
|GH786 |
|HH740 |
|IP90 |
|AH567 |
+-------+
I have thought about splitting the string at the first zero and remove the last character (the 0) of the first substring (and if the first character of the second substring starts with a zero as well, then remove the first character), but was wondering if there was a more elegant way.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)