Specifically: script = script[/[^\\d]+/, 0] if script
My guess is it's some sort of substring function, but it's hard to find documentation on the Googles about it.
It replaces string
with the first sequence of non-digit characters in script
if it is a string. It is a badly written code, and can be better written as
script &&= script[/\D+/]
The brackets are equivalent to ruby's match. The stuff within "/ /" is a regular expression.
The ^ means not. The \\d is for digits The + is for 1 or more
You would have to learn more about regular expressions, but i believe that it is saying replace the value of script (if it exists) with just the characters that arent digits.
Play around with http://rubular.com/ to get a better feel for 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.