gpt4 book ai didi

python - 选择向前看和向后看之间的部分

转载 作者:行者123 更新时间:2023-11-28 22:16:45 25 4
gpt4 key购买 nike

我想从工作信息中检索数据并输出结构化的 json,一个工作详细信息如下

In [185]: text = """Company
...:
...: Stack Overflow
...:
...: Job Title
...:
...: Student
...:
...: Job Description
...:
...: Our client is providing the innovative technologies, ....
...:
...: Requirements
...: .....
...: About the Company
...:
...: At ...., we are a specialized ..
...:
...: Contact Info
...: ...
...: """

我尝试用命名组提取

jobs_regex = re.compile(r"""
(?P<company>Company(?<=Company).*(?:=Job Title))
# the parts between "Company and Job Title
(?P<job_title>Job Title(?<=Job Title).*(?:=Job Description))
# the parts between "Job Title and Job Description
....
""",re.VERBOSE)

但是,当我运行它时得到空列表

In [188]: jobs_regex.findall(text)
Out[188]: []

如何解决环视问题 (?:) (?<=)?

最佳答案

我不知道你是否真的想使用 lookarounds 但这里有一个不使用它们的简单解决方案:

Company(?P<company>.*)Job Title(?P<job_title>.*)Job Description

关于python - 选择向前看和向后看之间的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51988151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com