'I need to replace my all the characters except ( ,* and +
For example in this below string
inParkBrake != 1 * inParamABAFunc= AVL * (ABA_Actv_Stat=NACT + ABA_Actv_Stat=SNA + ABA_Actv_Stat=ERR)
I need
inParkBrake != 1to be replaced with 'a'inParamABAFunc= AVLto be replaced with 'b'ABA_Actv_Stat=NACTto be replaced with 'c'ABA_Actv_Stat=SNAto be replaced with 'd'ABA_Actv_Stat=ERRto be replaced with 'e'
Expected Output ->
a * b * (c + d + e)
After this I am going to expand using expand function
import sympy
from sympy import expand, symbols
a, b, c, d, e = symbols('a b c d e')
print(expand(a*b*(c+d+e)))
The output for the above is
a*b*c + a*b*d + a*b*e
Now all the values are substitued back
That is
inParkBrake != 1 * inParamABAFunc= AVL * ABA_Actv_Stat=NACT + inParkBrake != 1 * inParamABAFunc= AVL * ABA_Actv_Stat=SNA + inParkBrake != 1 * inParamABAFunc= AVL * ABA_Actv_Stat=ERR
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
