I’m looking for a solution to replace a substring (id) without brackets before and after it.
Here’s my current code, very simple:
'deal[ptions_attributes][0][price]'.replace(/\[\d+\]/, '[new_id]'));
result: deal[ptions_attributes][new_id][price]
So I don’t really wont to use brackets in the new id – ‘[new_id]’ to replace substring with it.
Is there a way to ignore first ‘[‘ bracket while replacing and keep clean ‘new_id’ ?
This assumes that none of the other strings within
[...]end with digits