I'd like to ask you about the principle of this regularity.

/^(?:\/(?=$))?$/

this rule is used to match the

of an empty string.
"".match(/^(?:\/(?=$))?$/)
 ["", index: 0, input: "", groups: undefined]

"1".match(/^(?:\/(?=$))?$/)
 null

? = I know this is an antecedent assertion, which means that it must be followed by $.
but I don"t understand how the whole regular match is empty. (? = $) it has been defined that it must be followed by $, so if there is at least $, how can it be empty?


matches a blank row or data with only / in a row
such as:
Click to view


(? =) will be used as a matching check, but will not appear in the matching result string

(?:) is used as a match check and appears in the matching result character. It differs from (.) in that it is not returned as a child match.

var data = 'windows 98 is ok';
data.match(/windows (?=\d+)/);  // ["windows "]
data.match(/windows (?:\d+)/);  // ["windows 98"]
data.match(/windows (\d+)/);    // ["windows 98", "98"]
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5b622-66fca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5b622-66fca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?