regex মডিউল

ECMAScript-flavored regex (std::regex-চালিত)।

import "regex" as regex;

print(regex.test("\\d+", "hello 42"));           // true
print(regex.match("(\\w+)@(\\w+)", "[email protected]"));// ["[email protected]", "ada", "a"]
print(regex.replace("\\s+", "two  spaces", "_"));// "two_spaces"
print(regex.split(",\\s*", "a, b,c"));            // ["a", "b", "c"]

API

ফাংশনবর্ণনা
regex.test(pattern, s) → bools-এ কোথাও match হলে true।
regex.match(pattern, s) → list | nullপ্রথম match [full, group1, …], না হলে null
regex.match_all(pattern, s) → list of listsসব match।
regex.replace(pattern, s, replacement) → stringপ্রথম match replace। \1, \2 capture group রেফারেন্স।
regex.replace_all(pattern, s, replacement) → stringসব match replace।
regex.split(pattern, s) → listপ্রতি match-এ split।
regex.escape(s) → stringMetacharacter escape।

নোট

  • Pattern স্ট্রিং — backslash escape করুন ("\\d" = \d)।
  • কোনো regex literal সিনট্যাক্স নেই (/foo/g নেই)। Flag pattern-এ embed করুন ((?i) = case-insensitive)।