How to replace numbers after "/" by using Regex func?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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)
:bust_in_silhouette: Reply From: Thomas Karcher
var exp1 = "5 + 4/3 * √5"
var regex = RegEx.new()
regex.compile("\\/\\s*(\\d+)")
print(regex.sub(exp1, "/ float($1)"))

The pattern matches a forward slash followed by any number of whitespaces (including zero), followed by at least one digit. This match is then replaced with the string “/ float($1)”, where $1 represents the content of the first subgroup (= the digits).