字符串提取#

group strings_extract

函数

std::unique_ptr<table> extract(strings_column_view const &input, regex_program const &prog, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

返回一个字符串列的表,其中每列对应于给定的regex_program对象中指定的匹配组。

第一组的所有字符串将进入第一个输出列;第二组进入第二列,依此类推。如果第i行的字符串不匹配,则会在第i行的列中添加空条目。

任何空字符串条目返回相应的空输出列条目。

Example:
s = ["a1", "b2", "c3"]
p = regex_program::create("([ab])(\\d)")
r = extract(s, p)
r is now [ ["a", "b", null],
           ["1", "2", null] ]

有关此API支持的模式详情,请参见Regex Features页面。

Parameters:
  • input – 此操作的字符串实例

  • prog – 正则表达式程序实例

  • stream – 用于设备内存操作和内核启动的CUDA流

  • mr – 用于分配返回表的设备内存的设备内存资源

Returns:

从输入列中提取的字符串列

std::unique_ptr<column> extract_all_record(strings_column_view const &input, regex_program const &prog, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

返回一个字符串列表列,其中每个字符串列行对应于给定regex_program对象中指定的匹配组。

第一行的所有匹配组将进入第一行的输出列;第二行的结果将进入第二行的输出列,依此类推。

如果相应的输入字符串行不匹配或该输入行为空,则会产生空输出行。

Example:
s = ["a1 b4", "b2", "c3 a5", "b", null]
p = regex_program::create("([ab])(\\d)")
r = extract_all_record(s, p)
r is now [ ["a", "1", "b", "4"],
           ["b", "2"],
           ["a", "5"],
           null,
           null ]

有关此API支持的模式详情,请参见Regex Features页面。

Parameters:
  • input – 此操作的字符串实例

  • prog – 正则表达式程序实例

  • stream – 用于设备内存操作和内核启动的CUDA流

  • mr – 用于分配任何返回的设备内存的设备内存资源

Returns:

列出包含从输入列中提取的字符串的列