[comment]: # ({acf00dc8-acf00dc8})
# regexp.create

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

[comment]: # ({3c60fab5-3c60fab5})
### 描述

`object regexp.create(object/array regularExpressions)`

此方法允许create新的全局正则表达式.

::: noteclassic
此方法仅适用于*超级管理员*用户类型.
调用该方法的权限可在用户角色设置中撤销. 参见
[User
roles](/manual/web_interface/frontend_sections/administration/user_roles)
获取更多信息.

:::

[comment]: # ({/3c60fab5-3c60fab5})

[comment]: # ({ee8255df-f518ef9f})
### 参数

`(object/array)` 用于create的正则表达式.

除了[standard properties](object)之外，该方法还接受
以下参数.

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| expressions | array | [表达式](/manual/api/reference/regexp/object#表达式)选项. |

[comment]: # ({/ee8255df-f518ef9f})

[comment]: # ({f0011f1b-f0011f1b})
### 返回值

`(object)` 返回一个object对象，其中包含所创建正则表达式的ID，存储于`regexpids`属性下。

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

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

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

[comment]: # ({5d9be01d-3d653b4d})
#### 创建新的全局正则表达式

请求:

```json
{
    "jsonrpc": "2.0",
    "method": "regexp.create",
    "params": {
      "name": "Storage devices for SNMP discovery",
      "test_string": "/boot",
      "expressions": [
        {
          "expression": "^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$",
          "expression_type": "4",
          "case_sensitive": "1"
        }
      ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```
响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "regexpids": [
            "16"
        ]
    },
    "id": 1
}
```

[comment]: # ({/5d9be01d-3d653b4d})

[comment]: # ({cf9f5f19-cf9f5f19})
### 来源

CRegexp::create() 位于 *ui/include/classes/api/services/CRegexp.php* 文件中。

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