In GNU awk that'd be:
$ cat tst.awk
BEGIN {
str = "foo=23"
val = gensub(/foo=([0-9]+)/,"\\1","",str)
print "foo value is " val
}
$
$ gawk -f tst.awk
foo value is 23
In other awk's you'd need to use [g]sub() and/or match() and/or substr() depending on what else you do/don't want to match on. For example:
$ cat tst.awk
BEGIN {
str = "foo=23"
val = substr(str,match(str,/foo=[0-9]+/)+length("foo="))
print "foo value is " val
}
$ awk -f tst.awk
foo value is 23
You'd need a third arg of ',RLENGTH-length("foo=")' on the substr() call if the target pattern isn't at the end of a line. Make "foo=" a variable if you like and if it itself can contain an RE there's a few more steps necessary.