Issue
I have a string in my code like:
val string = "
|3
|<sup>3</sup>{{P|Mummy Zombie|2}}<sup>5</sup> {{P|Mummy Zombie|2}}
|None
"
The sample code is shorter, will have more <sup></sup>
{{zombie}} and the mummy zombie might be like conehead zombie, buckethead zombie... there is like a hundred types of zombies
how can i change it to like:
"
|3
|{{P|Mummy Zombie|2}}<sup>3</sup> {{P|Mummy Zombie|2}}<sup>5</sup>
|None
"
Solution
If you don't mind regex:
val s = """
|3
|<sup>3</sup>{{P|Mummy Zombie|2}}<sup>5</sup> {{P|Mummy Zombie|2}}
|None
"""
val regex = "(<[^>]+>[^>]+>)\\s*(\\{\\{[^}]+\\}\\})".toRegex()
println(s.replace(regex, "$2$1"))
Answered By - Darkman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.