As i am very new to regex, i can't find a way to detect mathematical expression based on pattern matching in regex.
Example : (p^(p=>q))=>q
I need to match the above expression with predefined patterns in array like a=>b, to take (p^(p=>q)) as 'a' and q as 'b', what makes it harder is, user can input the same expressions in any way, like with nested expressions.
Now, i have been struggling to modify the below regex pattern for nested parenthesis
/((?:(?=[^()]*\d)\d*(?:\.\d*)?)|(?:\((?:(?:[^()]+)|(?:[^()]*\([^()]*\)[^()]*)+)\)))\^((?:(?=[^()]*\d)\-?\d*(?:\.\d*)?)|(?:\((?:(?:[^()]+)|(?:[^()]*\([^()]*\)[^()]*)+)\)))/
Aucun commentaire:
Enregistrer un commentaire