line = window.get_clipboard('CLIPBOARD').wait_for_text()

#extract the first number from the clipboard
for i in range(len(line)):
    if line[i].isdigit():
        line = line[i:]
        break
for i in range(len(line)):
    if not line[i].isdigit():
        line = line[:i]
        break

try:
    line = int(line) - 1
except:
    pass
else:
    buf = window.get_active_doc().get_buffer()
    buf.place_cursor(buf.get_iter_at_line(line))
    window.focus_widget.scroll_to_iter(buf.get_iter_at_line(line), 0, True)