MS Access Replace() 函数

定义和用法

Replace() 函数用于在字符串中用另一个子字符串替换一个子字符串,可指定替换的次数。

实例

在字符串中将 "i" 替换为 "a":

SELECT Replace("My name is Willy Wonka", "i", "a") AS ReplaceString;

语法

Replace(string, find, replacement, start, count, compare)

参数

参数 描述
string 必需。原始字符串。
find 必需。要在 string 中搜索的子字符串。
replacement 必需。要在 string 中替换 find 的子字符串。
start 可选。在 string 中开始搜索的起始位置。如果省略,则 start 为 1。
count

可选。要执行的替换次数。

如果省略,它将使用 replacement 替换所有 find 的出现。

compare

可选。字符串比较的类型。

可能的值:

  • -1: 使用 Option Compare 的设置
  • 0: 二进制比较
  • 1: 文本比较
  • 2: 基于数据库中信息的比较

技术细节

适用于: 从 Access 2000 开始