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) → bool | s-এ কোথাও 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) → string | Metacharacter escape। |
নোট
- Pattern স্ট্রিং — backslash escape করুন (
"\\d"=\d)। - কোনো regex literal সিনট্যাক্স নেই (
/foo/gনেই)। Flag pattern-এ embed করুন ((?i)= case-insensitive)।