将正则匹配在带有正面的字符串之后,并在每个选择后面输入它
版权所有:Hololive Hololive_english
角色:mori_calliope takanashi_kiara takanashi_kiara_(凤凰)
艺术家:Xu_chin-wen
物种:
元:Web
我想在EG之后选择每个单词:字符:
,以便我可以将例如:字符:
在每个选择后面
字符:
mori_calliope字符:
takanashi_kiarachararcter:
takanashi_kiara_(phoenix)
我得到的最接近的东西是,我得到
(?<=(\w*):\s*\S*\s.*)(?<=\s)(?=\S)
的是正常工作的,但是当单身时它会破裂例如:字符:某物
或当它空的时,
如果有人会帮助我,我真的很感激
copyright: hololive hololive_english
character: mori_calliope takanashi_kiara takanashi_kiara_(phoenix)
artist: xu_chin-wen
species:
meta: web
I want to select every word after eg:character:
so i can put eg:character:
behind every selection,
character:
mori_calliopecharacter:
takanashi_kiarachararcter:
takanashi_kiara_(phoenix)
the closest thing i got is
(?<=(\w*):\s*\S*\s.*)(?<=\s)(?=\S)
which works properly but it breaks when there is a single entry on eg:character: something
or when its empty
i would be really thankfull if someone would help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该安装 pypi regex module 并使用
请参见 Regex Demo 。
详细信息:
(?其次是
:
char,然后除了尽可能多的挂断字符以外的任何零或更多字符?
See the Python demo :
输出:
You should install PyPi regex module and use
See the regex demo.
Details:
(?<=(\w+):.*)
- a positive lookbehind that matches a location that is immediately preceded with any word (captured into Group 1) followed by a:
char and then any zero or more chars other than line break chars as many as possible(?<=\s)` - a positive lookbehind that matches a location that is immediately preceded with a whitespace char
(?=\S)
- a positive lookahead that matches a location that is immediately followed with a non-whitespace char.See the Python demo:
Output: