javascript - Parse boolean arithmetic including parentheses with regex? -


Is there a regular expression that can parse the string (in Python and / or JavaScript, it does not need the expression ) Which represents the ordinary boolean arithmetic? For example, I want to parse this string:

  a and (b and c) and d or e and (f or g)  

Assume that:
* do not nest brackets *
Terms A, B, ..., Z are not sub-expressions

The resulting capture should be grouped by the parentheses first, Which I parsed again?

Any thoughts?

Any ideas?

Normally you will use this for example, but You can hold all the parts (tokens) with regex:

  x = 'a and (b and c) and d or e and (f or g)' import again Is = re.findall (r '\ (. *? \) | \ W +', x) Print ','. Included (mail)  

Operators usually have different variants. The evaluation of the parentheses will be done with the correct sequence from the left in the case of first, then and expression, and finally or expression, in the case of equal precedence. You say that you want to return the mails of parentheses first, but in fact what you normally do, the parts are used to make the express trade and recycle it continuously.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -