Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> JavaScript

JavaScript RegExp से स्क्वायर ब्रैकेट्स के बीच की वैल्यू कैसे प्राप्त करें?

उदाहरण

रेगुलर एक्सप्रेशन और इंडेक्स का उपयोग करके ब्रैकेट्स के बिना वैल्यू प्राप्त करें।

var regularExpression = /(?<=\[).*?(?=\])/g; 
var getTheValueWithIndex = "[John Smith][David Miller]".match(regularExpression); 
console.log("The first value without bracket=" + getTheValueWithIndex[0]); 
console.log("The second value without bracket=" + getTheValueWithIndex[1]);

प्रोग्राम चलाने के लिए:

node fileName.js

आउटपुट

PS C:\Users\Amit\JavaScript-code> node demo132.js 
The first value without bracket=John Smith 
The second value without bracket=David Miller
  1. - JavaScript में लिंक के id एट्रिब्यूट का मान कैसे प्राप्त करें?

    अवलोकनलिंक के id एट्रिब्यूट का मान प्राप्त करने के लिए id प्रॉपर्टी का उपयोग करें।उदाहरण<!DOCTYPE html> <html>    <body>       <p><a id="anchorid" hreflang="en-us" href="https://www.qries.com/">Qries</a></p

  1. - JavaScript में usemap एट्रिब्यूट का मान कैसे प्राप्त करें?

    अवलोकनusemap एट्रिब्यूट का मान प्राप्त करने के लिए useMap प्रॉपर्टी का उपयोग करें। यह क्लाइंट-साइड इमेज मैप को सक्षम करता है।उदाहरण<!DOCTYPE html> <html>    <body>       <img id="myid" src = "/images/html.gif" alt = "HTML Map&quo

  1. - JavaScript में लिंक के type एट्रिब्यूट का मान कैसे प्राप्त करें?

    अवलोकनलिंक के type एट्रिब्यूट का मान प्राप्त करने के लिए type प्रॉपर्टी का उपयोग करें। यह दस्तावेज़ के MIME प्रकार को दर्शाता है।उदाहरण<!DOCTYPE html> <html>    <body>       <p><a id="anchorid" type="text/html" target= "_bl