Class RegexTemplatingService
- Namespace
- FoundationaLLM.Common.Services.Templates
- Assembly
- FoundationaLLM.Common.dll
Templating engine that uses regular expressions to replace tokens in strings.
public class RegexTemplatingService : ITemplatingService
- Inheritance
-
RegexTemplatingService
- Implements
- Inherited Members
- Extension Methods
Constructors
RegexTemplatingService(ILogger<RegexTemplatingService>)
Templating engine that uses regular expressions to replace tokens in strings.
public RegexTemplatingService(ILogger<RegexTemplatingService> logger)
Parameters
logger
ILogger<RegexTemplatingService>The logger used for logging.
Methods
Transform(string, Dictionary<string, string>?)
Transforms the input string by replacing tokens with the corresponding values.
public string Transform(string s, Dictionary<string, string>? tokenAndValues = null)
Parameters
s
stringThe input string to be transformed.
tokenAndValues
Dictionary<string, string>Optional dictionary of well-known tokens and the values that should take its place.
Returns
- string
The transformed string where all the valid tokens have been replaced.