Xbasic

a5_stritran_multi_expression_Prepare Function

Syntax

C returned a5_stritran_multi_expression_Prepare(C txt )

Arguments

returned

sorted search/replace string. Character

txt

original search/replace string. Character

Description

Before stritran_multi_expression() is called, sort the search/replace string by the length (descending) of the search strings.

Discussion

Before stritran_multi_expressions() is called, sort the search/replace string by the length (descending) of the search strings.

Example

string = "this is parameter1 and this is parameter10 "

var1 = "alpha"
var2 = "beta"

sr = <<%txt%

parameter1=var1 
parameter10=var2 
%txt% 

?stritran_multi_expressions(string,sr)
= "this is alpha and this is alpha0 "  ''<<<---- not what we wanted

sr2 = a5_stritran_multi_expression_Prepare(sr)

?sr2
= parameter10=var2
parameter1=var1

'sr2 is now sorted by the length of the search string (the part before the = sign on each line of the string)

?stritran_multi_expressions(string,sr2)
= "this is alpha and this is beta "  '<<<<---- this IS what we wanted

See Also