Mailtraq - the Complete Email Server
   

Enstar for Mailtraq email server sales & support
Making world-class Internet technology affordable  

Search for:

Advanced search

WildcardMatchReplace()

Compares an input string with a wildcarded expression string and, via substitution using placeholders in a replacement string, returns an output string. String matches are case insensitive and the original case of input string characters are preserved if they appear in output string.

The input string must be less than 250 characters. Wildcards permitted in the expression string are ? (ASCII 63), which represents any single character, and * (ASCII 42) which matches zero or more characters. The placeholder used to generate the output string in the replacement string is $ (ASCII 36) and derivatives with numerical modifiers, for example $1 and $2 representing, respectively, the first and second wildcards in the expression string.

The expression string is pattern matched from right to left on the input string and returns the entire input string if the expression string cannot be anchored in the input string. As for the WildcardMatch() function, the * wildcard represents zero or more characters unless matching to the right hand end of the input string when it represents one or more characters.

output := WildcardMatchReplace( input , expression , replacement )

input
The input string
expression
A wildcarded string expression
replacement
A string containing placeholders which correspond to order of the wildcards used in expression
output
The output string
"quick" := WildcardMatchReplace("The quick brown fox", 
  "*the * brown*", "$2")
"Hello fox" := WildcardMatchReplace("The quick brown fox", 
  "*brown *", "Hello $2")
"The quick brown fox" := WildcardMatchReplace(
  "The quick brown fox", "* fox*", "$1")

Compare the result with the above when the right hand end of the input string is padded with a trailing space

"The quick brown" := WildcardMatchReplace("The quick brown fox ", 
  "* fox*", "$1")

The following expression demonstrates the use of placeholders

"Version1.27 [eng]" := WildcardMatchReplace(
  "Build 0027 Release 1 (eng)", 
  "Build ???? Release * (*)", "Version $5.$3$4 [$6]")

Clarification of placeholder values $1="0", $2="0", $3="2", $4="7", $5="1", $6="eng"

Mailtraq Highlights...
 SMTP Server     Mailtraq SMTP email server video IMAP Server     Mailtraq IMAP email Server video
 POP3 Server     Mailtraq POP3 email server video Proxy Server     Mailtraq proxy email server video
 Webmail Server     Mailtraq webmail email server video Mailing-list Server     Mailing list email server video
 Groupware Services     Mailtraq groupware email services video Spam and Virus control     Spam and virus control email server video

 

   Copyright © 2003 - 2011 Enstar Ltd, Enstar LLC & Fastraq Ltd. All rights reserved. Privacy policy.
   Mailtraq® is a registered trademark of Fastraq Limited.