[英]How to add whitespace & punctuation marks to capture first group with regex? How to stop certain tabs dividing into two columns within LibreOffice?
有人帮我 一直在尝试使此正则表达式正常工作,并且已经差不多了。 它们似乎都是正确的,但第一个应该是:
字词:el,la
性别:艺术
word_en:(+ m,f)
第一个测试字符串是:
1
el, la art the (+m, f)
• el diccionario tenía también frases útiles – the dictionary also had
useful phrases
2055835 | 201481381
另一个问题是我一直试图简单地复制信息。 从“替换”部分进入LibreOffice。 我要做的就是为数据创建6列。 问题是第六列(sent_en)有时可以在列'G'和'A'之间进行划分,而不是将send_en的所有数据都放在列'G'中。 如果将“替换”下的数据复制到LibreOffice Calc中,您将更好地理解我的意思。 我只是想不通,如果有人可以帮助我,我将非常感激。 谢谢。
这是链接https://regex101.com/r/m3yySN/2/
^
(?<frequency>[0-9]+) \W+
(?<word>\pL+\W?) \h+
(?<gender> [\pL()]+ (?:, \h* [\pL()]+)* ) \h+
(?<word_en> [^•]*[^•\s]) \h* \R
• \h*
(?<sent_esp> [^–]*[^\s–] ) \s*–\s*
(?<sent_en> .* (?:\R .*)*? ) \h* \R
(?<num1> [0-9]+) \h* \| \h*
(?<num2> .*\S)
\1\t\2\t\3\t\4\t\5\t\6\t
这个有点毛茸茸,但毕竟只需要进行一点调整即可:
^
(?<frequency>[0-9]+) \W+
(?<word>\pL+(?:,\h\pL+|\W)*) \h+
(?<gender> [\pL()]+ (?:, \h* [\pL()]+)* ) \h+
(?<word_en> [^•]*[^•\s]) \h* \R
• \h*
(?<sent_esp> [^–]*[^\s–] ) \s*–\s*
(?<sent_en> .* (?:\R .*)*? ) \h* \R
(?<num1> [0-9]+) \h* \| \h*
(?<num2> .*\S)
结果对我来说现在看起来不错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.