当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Processing Table.matchRow()用法及代码示例


Processing, 类Table中的matchRow()用法介绍。

用法

  • .matchRow(regexp, column)
  • .matchRow(regexp, columnName)

参数

  • regexp (String) 要匹配的正则表达式
  • column (int) 要搜索的列的 ID 号
  • columnName (String) 要搜索的列的标题

返回

  • TableRow

说明

Table 中查找与提供的正则表达式匹配的第一行,并返回对该行的引用。即使多行可能匹配,也只返回第一个匹配行。要搜索的列可以由其 ID 或标题指定。

例子

Table table;

void setup() {

  table = new Table();

  table.addColumn("name");
  table.addColumn("type");

  TableRow newRow = table.addRow();
  newRow.setString("name", "Lion");
  newRow.setString("type", "Mammal");

  newRow = table.addRow();
  newRow.setString("name", "Snake");
  newRow.setString("type", "Reptile");

  newRow = table.addRow();
  newRow.setString("name", "Mosquito");
  newRow.setString("type", "Insect");

  TableRow result = table.matchRow("R.*", "type");
  println(result.getString("name"));  // Prints "Snake"

}

相关用法


注:本文由纯净天空筛选整理自processing.org大神的英文原创作品 Table.matchRow()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。