[comment]: # translation:outdated

[comment]: # ({b75e4c49-b75e4c49})
# 正则表达式.获取

[comment]: # ({/b75e4c49-b75e4c49})

[comment]: # ({6303a1e7-15aa8348})
### 说明

`integer/array regexp.get(object parameters)`

使用该方式允许用户根据提供的参数检索选定的全局正则表达式。

::: noteclassic
该方式仅对*超级管理员*类型的用户生效。 用户可以在用户角色设置中对该方式的使用权限进行设定修改。请参考 [用户角色](zh/manual/web_interface/frontend_sections/administration/user_roles)以获取更多信息。
:::

[comment]: # ({/6303a1e7-15aa8348})

[comment]: # ({fe9a8e0b-9693dfa8})
### 参数

`(object)` 参数定义了用户想要获取的输出结果。

该方式支持下列所有参数配置。

|参数|[类型](zh/manual/api/reference_commentary#data_types)|说明|
|---------|---------------------------------------------------|-----------|
|regexpids|字符串/数组|只返回带有固定ID的正则表达式。|
|selectExpressions|搜索请求|返回单个[公式](zh/manual/api/reference/regexp/object#expressions_object) 属性。|
|sortfield|字符串/数组|以设定的属性对结果进行分类整理。<br>返回的可能数值为：`regexpid` 和`name`。|
|countOutput|布尔值|该类型参数普遍通过`get`的方式获取并详细描述在[引用评论](zh/manual/api/reference_commentary#common_get_method_parameters)中。|
|editable|布尔值|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/fe9a8e0b-9693dfa8})

[comment]: # ({7223bab1-7223bab1})
### 返回数值

`(integer/array)`将返回以下两种数值中的任意一种：

-   一组有关对象的数组；
-   若在使用`countOutput`参数的前提下，那么将会返回检索对象的总数。

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### 参考示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({755186c1-196e1642})
#### 检索全局正则表达式。

请求：

```json
{
    "jsonrpc": "2.0",
    "method": "regexp.get",
    "params": {
        "output": ["regexpid", "name"],
        "selectExpressions": ["expression", "expression_type"],
        "regexpids": [1, 2],
        "preservekeys": true
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应：

```json
{
  "jsonrpc": "2.0",
  "result": {
    "1": {
      "regexpid": "1",
      "name": "File systems for discovery",
      "expressions": [
        {
          "expression": "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$",
          "expression_type": "3"
        }
      ]
    },
    "2": {
      "regexpid": "2",
      "name": "Network interfaces for discovery",
      "expressions": [
        {
          "expression": "^Software Loopback Interface",
          "expression_type": "4"
        },
        {
          "expression": "^(In)?[Ll]oop[Bb]ack[0-9._]*$",
          "expression_type": "4"
        },
        {
          "expression": "^NULL[0-9.]*$",
          "expression_type": "4"
        },
        {
          "expression": "^[Ll]o[0-9.]*$",
          "expression_type": "4"
        },
        {
          "expression": "^[Ss]ystem$",
          "expression_type": "4"
        },
        {
          "expression": "^Nu[0-9.]*$",
          "expression_type": "4"
        }
      ]
    }
  },
  "id": 1
}
```

[comment]: # ({/755186c1-196e1642})

[comment]: # ({71855296-71855296})
### 参考来源

CRegexp::get() in *ui/include/classes/api/services/CRegexp.php*.

[comment]: # ({/71855296-71855296})
