কম্পিউটার

জাভাস্ক্রিপ্ট কম্পাইল() পদ্ধতি


জাভাস্ক্রিপ্ট কম্পাইল() পদ্ধতিটি স্ক্রিপ্ট এক্সিকিউশনের সময় একটি রেগুলার এক্সপ্রেশন কম্পাইল করার জন্য ব্যবহার করা হয়। এটি জাভাস্ক্রিপ্ট সংস্করণ 1.5.

এ অবমূল্যায়িত হয়েছে

নিচে জাভাস্ক্রিপ্ট কম্পাইল() মেথড -

-এর কোড দেওয়া হল

উদাহরণ

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
</style>
</head>
<body>
<h1>compile() Method</h1>
<p class="sample">
That man won the race and the woman over there came second
</p>
<h3>After compile()</h3>
<p class="result"></p>
<button class="Btn">Click Here</button>
<h3>Click the above button to use compile the regex to make changes</h3>
<script>
   let sampleEle = document.querySelector(".sample");
   let result = document.querySelector(".result");
   document.querySelector(".Btn").addEventListener("click", () => {
      var str = sampleEle.innerHTML;
      var pattern = /man/g;
      var str2 = str.replace(pattern, "person");
      result.innerHTML = str2 + "<br>";
      pattern = /(wo)?man/g;
      pattern.compile(pattern);
      str2 = str.replace(pattern, "person");
      result.innerHTML += str2;
   });
</script>
</body>
</html>

আউটপুট

জাভাস্ক্রিপ্ট কম্পাইল() পদ্ধতি

"এখানে ক্লিক করুন" বোতামে ক্লিক করলে -

জাভাস্ক্রিপ্ট কম্পাইল() পদ্ধতি


  1. জাভাস্ক্রিপ্ট getTime() পদ্ধতি

  2. JavaScript Sort() পদ্ধতি

  3. জাভাস্ক্রিপ্টে Object.fromEntries() পদ্ধতি।

  4. জাভাস্ক্রিপ্টে array.flatmap() পদ্ধতি।