I need to get certain words from a string in a new format. For example, I call a function with the input:
text2function('$sin (x)$ is an function of x')
and I need to put them in a StringFunction:
StringFunction(function, independent_variables=[vari])
where I need to get only "sin (x)" for the function and "x" for var. So it will look like this:
StringFunction('sin (x)', independent_variables=['x']
The problem is that I cannot get the function and variable. I tried:
start = string.index(start_marker) + len(start_marker)
end = string.index(end_marker, start)
return string[start:end]
and
r = re.compile('$()$')
m = r.search(string)
if m:
lyrics = m.group(1)
and
send = re.findall('$([^"]*)$',string)
Everything seems to give me nothing. Am I doing something wrong? All help is appreciated. Thank.
source
share