我如何获得subString?

时间:2015-08-14 13:20:10

标签: ios string swift substring

有人可以告诉我如何从字符串中获取子字符串吗?我用substring和rangeOfString方法尝试了所有方法,但无法解决它... 我的文字是这样的:

var text = "Suuuuper, {1} has sent {2} a very cool present"

我的文字可以在{1}之前和{2}之后变化,所以我想我必须首先得到" {1}"的索引。和" {2}"然后得到子串。

我想最终:

var myTextBefore{1}: String = ...

var myTextAfter{2}: String = ...

提前致谢。

1 个答案:

答案 0 :(得分:3)

您可以使用#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN price ON stock.stock_code = price.stock_code WHERE stock.stoc' at line 3 canvas.toBlob(function (blob) { var url = window.URL || window.webkitURL; var imgSrc = url.createObjectURL(blob); var img = new Image(); img.src = imgSrc; img.onload = function () { var pdf = new jsPDF('p', 'px', [img.height, img.width]); pdf.addImage(img, 0, 0, img.width, img.height); pdf.save(fileName + '.pdf'); }; }); rangeOfString方法:

substringToIndex