Class Replace
- Namespace
- YndigoBlue.Velocity.Functions
- Assembly
- YndigoBlue.Velocity.dll
Represents the REPLACE string function that substitutes all occurrences of a substring with another.
public class Replace : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
- Inheritance
-
Replace
- Implements
Remarks
The REPLACE function finds all occurrences of a search string and replaces them with a replacement string. This is useful for data cleansing, standardization, or text transformation. The search is typically case-sensitive, depending on database collation settings.
Examples
Replace all hyphens in a product code with underscores:
var schema = manager.LoadSchema("catalog");
var products = schema["products"];
var query = new Query()
.Select([ products["id"], new Expression("normalized_code", new Replace(products["code"], "-", "_")) ])
.From(products);
var results = manager.Retrieve(query);
Constructors
- Replace(IElement, IElement, IElement)
Initializes a new instance of REPLACE with generic elements.
- Replace(Column, string, string)
Initializes a new instance of REPLACE with literal search and replacement values.
- Replace(Column, Column, Column)
Initializes a new instance of REPLACE with column-based search and replacement values.
- Replace(Expression, string, string)
Initializes a new instance of REPLACE for a string expression with literal values.