Scenario:
The user can enter any number of parentheses pairs into an equation in String format. However I need to check to be sure that all parentheses '(' or ')' have an adjacent multiplier symbol ''. Hence '3(' should be '3(' as ')3' should be ')3'.
I need to replace all occurrences of possible 'n(' with 'n(' and ')n' with ')*n'.
Example: 1+5(3+4)7/2 ---> 1+5*(3+4)7/2
What is the correct regex what to do this?
I was thinking of something like '[0-9](' & )[0-9]'. But I don't know the full syntax of search for all assurances of patterns to be replaced with '' insert.
Aucun commentaire:
Enregistrer un commentaire