【发布时间】:2019-07-01 20:19:44
【问题描述】:
我正在尝试从特定标记语言 LookML 中提取某些数据。如果这是示例代码:
explore: explore_name {}
explore: explore_name1 {
label: "name"
join: view_name {
relationship: many_to_one
type: inner
sql_on: ${activity_type.activity_name}=${activity_type.activity_name} ;;
}
}
explore: explore_name3 {}
然后我会收到一个如下所示的列表:
explore: character_balance {}label: "name" join: activity_type { relationship: many_to_one type: inner sql_on: ${activity_type.activity_name}=${activity_type.activity_name} ;; }```explore: explore_name4 {}
基本上,我在 "explore" 处开始一场比赛,并在找到另一个 "explore" 时结束比赛——这将开始下一场比赛。
这是我以前的内容,它匹配所有行,直到找到;,这非常好:'explore:\s[^;]*'。但是,假设有一个,这停在一个';'。
我将如何更改它以消除“探索”和“探索”之间的所有内容?只需替换';'在我的 'explore' 正则表达式中,只要找到与 [e,x,p,l,o,r,e] 中的任何内容匹配的字母就会停止 - 这不是我想要的行为。删除方括号和 ^ 最终会破坏所有内容,使其无法跨多行查询。
我应该在这里做什么?
【问题讨论】:
标签: python regex regex-lookarounds looker