ASP VBScriptは、string.format文字列フォーマットを実装します



Asp Vbscript Implements String



'String Format Format 'str formatted string 'strArry placeholder array, array index must match the placeholder number function FormatString(str,strArry) dim tempStr,index tempStr=str index=0 for each val in strArry dim placeholder placeholder='{'+Cstr(index)+'}' tempStr=Replace(tempStr,placeholder,val) index=index+1 next FormatString=tempStr end function

使用する

dim str、stra(3)
str = 'ab {0} c {1} {2} dd {1}'
stra(0)= '00'
stra(1)= '11'
stra(2)= '22'
FormatString(str、stra)



出力

ab00c1122dd11