diff --git a/index.js b/index.js index db0b75c97b4360244e90188d3507410642455849..375cf2b773183912c1be2e486373f771c9081ba6 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,17 @@ -function equalToken(model) { - let unitPrice = 1/1000000; // 1token 是多少钱 - if (model.currency === 'USD') { - const exchangeRate = 7; - return (model.price / unitPrice) / exchangeRate; - } - return model.price / unitPrice; -} +function listToArray(data) { + const regex = /^-(\s+-)?(.+)/gm; + const matches = data.match(regex); + if (!matches) return []; + return matches.map(line => line.replace(/^-(\s+-)?/, '').trim()); +}; -const model = { - price: 0.0014, - currency: 'USD' -} +const data1 = `- - 《星际穿越》中时间与物理的主题是如何体现的? +- - 电影《肖申克的救赎》中,安迪如何体现了自由与救赎的主题? +- - 在《教父》中,家族与权力的冲突是如何表现的?` -const token = equalToken(model); +const data2 = `- 《星际穿越》中时间与物理的主题是如何体现的? +- 电影《肖申克的救赎》中,安迪如何体现了自由与救赎的主题? +- 在《教父》中,家族与权力的冲突是如何表现的?` -console.log(token); \ No newline at end of file +console.log(listToArray(data1)) +console.log(listToArray(data2)) \ No newline at end of file