const regex = new RegExp('[\\#(/)_\\-\\=\\!\\:]', 'gm')
const str = `#/usr/bin/python3
from bisect import bisect_right
def binary_search(vector,x):
i = bisect_right(vector,x)
if i != len(vector)+1 and vector[i-1] == x:
return i-1
return -1
def is_prime(vector,number):
return 1 if binary_search(vector,number) != -1 else 0
def prime_vector(num):
ret = []
for a in range(2,num+1):
if a == 2 or a == 3 or a == 5 or a == 7 or a == 11:
ret.append(a)
elif a %2 == 0 or a%3 == 0 or a%5 == 0 or a%7==0 or a%11 == 0:
continue
else:
ret.append(a)
return ret
number = int(input())
prime = prime_vector(number)
ret = []
p = 0
while number:
if is_prime(prime,number):
ret.append(number)
break
elif number%prime[p] == 0:
ret.append(prime[p])
number = int(number / prime[p])
else:
p = p + 1
for a in range((len(ret))):
print(ret[a],end=" ")
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions