![](/img/trans.png)
[英]Remove the last word of a string if the last before word is a number and increment the number - JS
[英]Increment last number in string
給出以下字符串:
Backticks[0].Folders[0]
我需要增加后一個數字。
我不是Regexp替換的專家,我試過這個,但它也選擇了支架。
href = href.replace(/\d+]$/gi, matchedNumber++);
是否可以在一個襯管中進行選擇,增量和更換?
它有可能在一個行做
'Ace[0].Folders[0]'.replace(/\d+(?=]$)/, function(i) { return parseInt(i) + 1; })
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.