JavaScript input Property: Array Object
Description
The input property is a read-only property. It contains the original string against which the regular expression was matched.
Version
Implemented in JavaScript 1.1
Syntax
array.input
Example:
In the following web document a regular expression string that contains the search string 'fox'. The match() method is used to find the regular expression within the string 'str1'. The input property is used to display the string that was searched.
HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf8"/>
<title>JavaScript Array Object - input Property example</title>
<style type="text/css">
h1 {color:red}
</style>
</head>
<body>
<h1>JavaScript Array Object : Input property</h1>
<script src="array-input-example1.js">
</script>
</body>
</html>
JS Code
var mymatch=/fox/;
var array1= mymatch.exec("The quick brown fox jumps over the lazy dog.");
var newParagraph = document.createElement("p");
var newText = document.createTextNode("The word 'fox' is found in the string : "+array1.input);
newParagraph.appendChild(newText);
document.body.appendChild(newParagraph);
View the example in the browser
Practice the example above online
JavaScript Array Object - input Property exampleSee also :
JavaScript Core objects, methods, properties.
Previous: JavaScript index Property: Array Object
Next: JavaScript length Property: Array Object
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/javascript/object-property-method/array-input.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics