Invalid escape in regex – unable to convert from regex to html input pattern [duplicate]

I need help to make the html input pattern to work correctly with the following regexp:

/^([0-9]+(.[0-9]*[1-9]|);)*[0-9]+(.[0-9]*[1-9]|)+$/mg

This expression only allow a infinite group of positive numbers, with or without a decimal fraction marked with a point, separated by semicolon. For example:

23;23.3;444

I tried:

document.querySelectorAll("input")[0].pattern="^([0-9]+(.[0-9]*[1-9]|);)*[0-9]+(.[0-9]*[1-9]|)+$";

But in the html pattern, allows:

23;23.3;444;44-4;44,4

Using JS works perfectly:

regex = /^([0-9]+(.[0-9]*[1-9]|);)*[0-9]+(.[0-9]*[1-9]|)+$/mg;
regex.test("541.4;4;3;3.3;33;33;45.5;443;4");  //true
regex.test("541.4;4;3;3.3;33;33;45.5;4-43;4"); //false

Any ideas how to fix this html pattern? Thank you.