How to replace question marks inside a string with the values of an array?

前端 未结 5 1190
别那么骄傲
别那么骄傲 2020-12-03 19:11

Given the string \'Hello ?, welcome to ?\' and the array [\'foo\', \'bar\'], how do I get the string \'Hello foo, welcome to bar\' in

5条回答
  •  一整个雨季
    2020-12-03 19:47

    You could use vsprintf. Although if you include sprintf, it's much more than one line.

    vsprintf('Hello %s, welcome to %s', [foo, bar]);
    

提交回复
热议问题