How to use regular expressions to solve binary equations
Xiaobian to share with you how to use regular expressions to solve binary equations, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article. Let's take a look at it!
I really calculated the result according to the regularity written in the original text. Example on php:
Let me explain.
Let's put it in a simple formula: 2x+3y=9
Principle:
Generate such a rule in this function
^ (. *)\ 1 {1} (. *)\ 2 {2} $
To match a repeating string "-" of length 9, and match the length of the two groups, which is the value of his x and y.
Regular explanation:
[(. *)] that is, 0 to countless [.] periods.
\ 1 is to quote a group. The following [{1}] is repeated once.
The second half is\ 2, which is to quote 2 groups. The following [{2}] is repeated once.
The following is the translation of the English blog:
The binary equation 17x + 12y = 51, its expression [^ (. *)\ 1 {16} (. *)\ 2 {11} $]. It's easy to understand. [(. *)] that is, 0 to countless [.] periods. (here is what I said above. In fact, the [.] dot is meant to represent the character "1".)
That is, 0 to countless 1s, which will be referenced once in [\ 1]. Then [{16}] is 16 times. Acts on the previous [\ 1], that is, 16 references. Plus the initial [(. *)], there are exactly 17 times. I won't talk about the last one, just like this one.
The regular engine tries to add 0 to countless characters "1", 0 characters "1", 1 character "1", and 2 characters "1" in [(. *)]. Until successful, try the maximum number of all characters "1" (51 characters "1" in this case).
The above is all the content of the article "how to use regular expressions to solve binary equations". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!