fork download
  1. import re
  2. s = "@romeo went to @juliet and said hi, I'm @romeo"
  3. print(re.sub(r"\B(?<!@)@(\w{1,31})", r'<a href="/u/\1">\g<0></a>', s))
Success #stdin #stdout 0.02s 9632KB
stdin
Standard input is empty
stdout
<a href="/u/romeo">@romeo</a> went to <a href="/u/juliet">@juliet</a> and said hi, I'm <a href="/u/romeo">@romeo</a>