Home > Article > Web Front-end > Introduction to the usage of js clipboard (clipboardData.setData) and js match function_javascript skills
I often see this effect: clicking a button copies the content in a certain area to the clipboard. In fact, this function is not difficult to implement. The core is to use a method of the window sub-object clipboardData: setData()
Syntax:
clipboardData.setData(sDataFormat, sData)
Parameters: sDataFormat: the format of the content to be copied; sData: the content to be copied.
Return value: Returns true if the copy is successful; returns false if it fails.
where stringObj is required. The String object or string literal to search for.
rgExp is required. Is a regular expression object containing the regular expression pattern and available flags. Can also be a variable name or string literal containing a regular expression pattern and available flags.
If the match function method in js does not find a match, return null. If a match is found an array is returned and the properties of the global RegExp object are updated to reflect the match. The array returned by the match function method in JavaScript has three attributes: input, index and lastIndex. The Input property contains the entire searched string. The Index property contains the position of the matching substring within the entire string being searched for. The LastIndex property contains the position next to the last character in the last match. If the global flag (g) is not set, element 0 of the array contains the entire match, and elements 1 to n contain any submatches that occurred in the match. This is equivalent to the exec method without setting the global flag. If the global flag is set, elements 0 to n contain all matches.
The following example demonstrates the usage of the match function method in js: