title: "给定 /^"([^"]+)" replaced with "([^"]+)" in the ([^\s]+) file$/" post_status: publish comment_status: open taxonomy: category: - wp-cli-handbook post_tag: - Behat Steps - References - Repos
给定 /^"([^"]+)" replaced with "([^"]+)" in the ([^\s]+) file$/
使用正则表达式在文件中搜索并替换字符串。
用法
Scenario: 我的示例场景
Given "Foo" replaced with "Bar" in the readme.html file
...
Behat 步骤文档在每次发布时从 WP-CLI 代码库生成。如需改进,请提交拉取请求。
相关
- Given an empty directory - 创建一个空目录。
- Given /^an? (empty|non-existent) ([^\s]+) directory$/ - 创建或删除一个特定目录。
- Given an empty cache - 清空 WP-CLI 缓存目录。
- Given /^an? ([^\s]+) (file|cache file):$/ - 创建具有给定内容的文件。
- Given /^that HTTP requests to (.*?) will respond with:$/ - 模拟对给定 URL 的 HTTP 请求。
- Given WP files - 下载 WordPress 文件但不安装。
- Given wp-config.php - 使用 `wp config create` 创建 wp-config.php 文件。
- Given a database - 创建一个空数据库。
- Given a WP install(ation) - 安装 WordPress。
- Given a WP install(ation) in :subdir - 在给定目录中安装 WordPress。
- Given a WP install(ation) with Composer - 使用 Composer 安装 WordPress。
- Given a WP install(ation) with Composer and a custom vendor directory :vendor_directory - 使用 Composer 和自定义供应商目录安装 WordPress。
- Given /^a WP multisite (subdirectory|subdomain)?\s?(install|installation)$/ - 安装 WordPress 多站点。
- Given these installed and active plugins: - 安装并激活一个或多个插件。
- 给定一个自定义的 wp-content 目录 - 配置一个自定义的 `wp-content` 目录。
- 给定下载: - 将多个文件下载到指定的目标位置。
- 给定 /^保存 (STDOUT|STDERR) ([\'].+[^\'])?\s?为 \{(\w+)\}$/ - 将 STDOUT 或 STDERR 的内容存储在一个变量中。
- 给定 /^一个具有(相同版本|版本 "([^"]+)")的新 Phar$/ - 使用指定版本构建一个新的 WP-CLI Phar 文件。
- 给定 /^一个具有(相同版本|版本 "([^"]+)")的已下载 Phar$/ - 从 GitHub 下载特定版本的 WP-CLI Phar 文件。
- 给定 /^将 (.+) 文件 ([\'].+[^\'])?保存为 \{(\w+)\}$/ - 将指定文件的内容存储在一个变量中。
- 给定一个配置错误的 WP_CONTENT_DIR 常量目录 - 修改 wp-config.php 文件,将 `WP_CONTENT_DIR` 设置为空字符串。
- 给定对当前 wp-cli 的依赖 - 将 `wp-cli/wp-cli` 添加为 Composer 依赖项。
- 给定一个 PHP 内置 Web 服务器 - 在当前目录启动一个 PHP 内置 Web 服务器。
- 给定一个 PHP 内置 Web 服务器来服务 :subdir - 在指定的子目录中启动一个 PHP 内置 Web 服务器。