def match(regexp): this.c*k() s = this.to_string() r = this.RegExp(regexp) if regexp.Class!='RegExp' else regexp if not r.glob: return Exec(r, s) r.put('lastIndex', this.Js(0)) found = [] previous_last_index = 0 last_match = True while last_match: result = Exec(r, s) if result.is_null(): last_match=False else: this_index = r.get('lastIndex').value if this_index==previous_last_index: r.put('lastIndex', this.Js(this_index+1)) previous_last_index += 1 else: previous_last_index = this_index matchStr = result.get('0') found.append(matchStr) if not found: return this.null return found
def match(regexp): this.c*k() s = this.to_string() r = this.RegExp(regexp) if regexp.Class != 'RegExp' else regexp if not r.glob: return Exec(r, s) r.put('lastIndex', this.Js(0)) found = [] previous_last_index = 0 last_match = True while last_match: result = Exec(r, s) if result.is_null(): last_match = False else: this_index = r.get('lastIndex').value if this_index == previous_last_index: r.put('lastIndex', this.Js(this_index + 1)) previous_last_index += 1 else: previous_last_index = this_index matchStr = result.get('0') found.append(matchStr) if not found: return this.null return found
def match(regexp): this.c*k() s = this.to_string() r = this.RegExp(regexp) if r.glob: return Exec(r, s) r.put('lastIndex', this.Js(0)) found = [] last_index = n = 0 while True: res = Exec(r, s) if res.is_null(): break index = res.get('lastIndex').value if last_index==index: r.put('lastIndex', index+1) last_index = index + 1 else: last_index = index found.append(res.get('0')) n += 1 if not n: return this.null return found
def match(regexp): this.c*k() s = this.to_string() r = this.RegExp(regexp) if r.glob: return Exec(r, s) r.put('lastIndex', this.Js(0)) found = [] last_index = n = 0 while True: res = Exec(r, s) if res.is_null(): break index = res.get('lastIndex').value if last_index == index: r.put('lastIndex', index + 1) last_index = index + 1 else: last_index = index found.append(res.get('0')) n += 1 if not n: return this.null return found