Let's imagine you have a string that starts with a number that conforms to the pattern:
1 to 5 digits + decimal separator + 2 digits
This pattern may be followed with any character, even including a newline. Then, in JS, you can use the following replacement:
.replace(/^(\d{1,5}[.,]\d{2})[\s\S]*/, "$1")
Where
^ - matches the start of the string
(\d{1,5}[.,]\d{2}) - matches and captures our pattern (with , or . as decimal separators)
[\s\S]* - matches any 0+ characters, even including a newline.
var re = /^(\d{1,5}[.,]\d{2})[\s\S]*/;
var str = '12323.098765421';
var result = str.replace(re, "$1");
console.log(result);
The $1 is a backreference to the value captured with Group 1 (formed with the help of a pair of unescaped parentheses).
See more information on capturing groups and backreferences.
12323.09? See regex101.com/r/jF5tV6/1. But why remove? You can useRegExp#match:"12323.098765421".match(/^\d{1,5}[.,]\d{2}/)[0].can't understand what should I put here to replace first partpart.