简体   繁体   中英

What's the meaning of ?= right after ^?

Following is one of strong password validation that at least six characters and contains a digit, symbol, or punctuation mark.

(?x)^(?=.* ( \d | \p{P} | \p{S} )).{6,}

What's the meaning of (?=.* after (?x)^ ?

I understand ?= expr is Lookahead that checks whether the text that follows matches expr. But in this case, only ^ that is start of a string is ahead.

In words:

The comments flag is set ( (?x) ).

The start of the string ( ^ ) must be first, which must be followed by ( ?= ) zero or more characters ( .* ), then either ( (||) ) a digit ( \\d ), a punctuation mark ( \\p{P} ) or a symbol ( \\p{S} ).

After the start of string, there must be 6 or more of any characters ( .{6,} )

Does that explain it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM