Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Konrad |
How do I find the text after the sign “/”. For example in the expression:
5 + 10 / 5 - 1
i need to find 5
and replace with float(5) or 5.0.
I tried to find the numbers that stand after /
,but it didn’t work out for me. Thanks for the help.
it should replace to 5 + 10/ float(5) - 1
my bad code :
var exp1 = "5 + 4/3 * √5"
var regex = RegEx.new()
regex.compile(" (i dont know) ")
var result = regex.search(exp1)
var final = exp1
if result != null:
var rep = "float(%s)" % [result.get_string(1)]
final = exp1.replace(result.get_string(0), rep)
print(final)