如何使用 re2 正则表达式提取单个句号即忽略`...`之间的所有文本?

问题描述

如何使用 re2 正则表达式提取单个句号之间的所有文本(即忽略 listItems.getChildren('OneLineTextElement','type') .getChildren('LabelAndValue') .getChild('Label') .getProperty('texture-text') .should(val => { expect(val).to.equal(subject); cy.action('ENTER'); }) )?

我在 BigQuery 中使用 ... 函数,它使用 https://github.com/google/re2/wiki/Syntax

来自以下示例:

REGEXP_EXTRACT_ALL

我希望提取查询

This is... a.. sentence. It is just an example.This is... a.. sentence.

我特别感兴趣的是是否可以在 BigQuery 中使用 sql 函数而不是引入其他工具

解决方法

考虑以下解决方法

select text,regexp_replace(sentence,r'(#)(\.+)(#)',r'\2') sentence
from `project.dataset.table`,unnest(split(trim(regexp_replace(regexp_replace(text,r'(\.+)',r'#\1#'),r'(\#\.\#)',r'####'),'####'),'####')) sentence 

如果应用于您问题中的样本数据 - 输出为

enter image description here