js 正则如何匹配指定字符前面的几位,替换成指定字符串?

需求 "{1631660046=[Info(cardX=45.83473, cardY=45.56563, cardId=54257, floorId=1, staticStartTime=1631660170, uuid=2155)],1631660047=[Info(cardX=45.83473, cardY=45.56563, cardId=54257, floorId=1, staticStartTime=1631660170, uuid=2155)]} "
替换成"{arr:[Info(cardX=45.83473, cardY=45.56563, cardId=54257, floorId=1, staticStartTime=1631660170, uuid=2155)],arr:[Info(cardX=45.83473, cardY=45.56563, cardId=54257, floorId=1, staticStartTime=1631660170, uuid=2155)]} "
最新回答
柒槿年

2024-10-31 09:44:08

题主你好,


匹配的内容为:   /d{1,}=

替换的内容为:   arr:

加上全局替换标志g, 否则只会替换第一个.

*****测试代码*****


*****结果*****

-----

希望可以帮到题主, 欢迎追问.