js regular first assertion,

Primer before the regular school mostly a relatively rigid buckle a sometimes encounter difficulties is online plagiarism, very cumbersome, laborious. Bored at night under regular learning.

First look at an example, matching a password, but there must be letters and numbers, which is a more common case online column;

/^(?=.*[0-9])(?=.*[a-z])[0-9A-Za-z]{6,12}$/
  1. First look at? = The mean anything, (? = Exp), also known as zero-width positive lookahead assertion, it asserts itself behind the appearance of the location can match the expression exp. Such as \ b \ w + (? = Ing \ b), matched to the front end portion of the word ing (except ing part), such as finding I'm singing while you're dancing., It will match sing and danc . Here quoted from "regular 30 minutes introductory essay course", http://deerchao.net/tutorials/regex/regex.htm#more ;
  2. That? = Says he asserted his position that appears to match the expression behind, said bluntly, he is here to do the restriction, the expression must conform to the back of the label. That do here what limits?
  3. This place is a bit difficult to understand for me. Look it personal. He could not match the character, he is a match for the position, remember the location, $ ^ these are matched position;
  4. Complete concerned, I followed at the beginning ^ position, can also be understood in the beginning, I have spoken, behind the expression, all with my performance content * [0-9] matches any character I, but you must give me back numbers must have
  5. There must be said that the digital Well, have on the line. But this range is actually very, very far away from you match what the gap, so the next big rule there is little rule;

  6. [0-9A-Za-z] {6,12} $ This is a small rule, under the premise of meeting the big rules, I also specifically bound by it. Boss said arbitrary characters match letters and numbers on the list, but here I have to match alphanumeric, as well as the number of requirements. This is a concrete match. Look at an example,

    Boss said, to meet his conditions, I think in the back to add a .com look okay, shaped like this format

  7. This is not enough to match the boss is the location, condition is satisfied. This is something specific you ah, here we must clarify the relationship between the location, and specific characters. .com is actually to match. But how had got?

  8. I now write expressions to meet the boss meant it,
  9.  This trip, to meet in front of the assertion, later match the actual character we need to meet, once there is a conflict, it will not match.

Guess you like

Origin www.cnblogs.com/manu-yyj/p/11247749.html