const regex = /^.*?\Kidr.?\s*[\d.,]+|
.*?\Krp.?\s*[\d.,]+|
.*?\Kprice\s*:?\s*[\d.,]+|
.*?\K\s\d+\s?k\s|
.*?\K\d+rb|
.*?\K[0-9.,]+\s*ribu|
.*?\K\b\d+[.,]\d+[.,]?\d+/is;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^.*?\\Kidr.?\\s*[\\d.,]+|
.*?\\Krp.?\\s*[\\d.,]+|
.*?\\Kprice\\s*:?\\s*[\\d.,]+|
.*?\\K\\s\\d+\\s?k\\s|
.*?\\K\\d+rb|
.*?\\K[0-9.,]+\\s*ribu|
.*?\\K\\b\\d+[.,]\\d+[.,]?\\d+', 'is')
const str = `"ABBY TOP
Colour : POLKA BLACK
Weight : 0,18
Price : 185,000
Material : Kaos Semi-Fleece
Size : Panjang / Length: 55 cm (depan), 72 (belakang)"`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions