import re
import unicode
var txt = "自我 我们 我" # this is actually read from external file
#~ txt = txt.toRunes()
# type mismatch: got <seq[Rune]> but expected 'string'
var result = txt.findall(re".{0,1}我.{0,1}")
for i in result:
echo i # "自我", "我们", "我" are expected
will display
▒我
我▒
我
as the code says, if I convert txt to runes, then the txt.findall says "type mismatch: got <seq[Rune]> but expected 'string'". But the above code does not find the whole unicode characters around "我" which is not right answer
So any suggestion? Thanks
Try this:
import nre
let txt = "自我 我们 我" # this is actually read from external file
let r = re"(*U).{0,1}我.{0,1}"
for res in findAll(txt, r):
echo res
Show for me:
自我
我们
我
Could you point us to some docs on this (*U) syntax? I've never seen that.