A regex question

I have a li element that contains the string:

Product weight 2.7 kg
or
Product weight 12 kg

So I use a regex
([^\s]+) kg

It checks out OK in https://regex101.com/ returning 2.7, 12 etc. but in webscraper it returns 2.7 kg and 12 kg. i.e. including the units that I don't need. How do I fix this?

I realise regex is depricated in the Chrome extension, but it still works on existing sitemaps and it seems to be possible to add regex directly by editing the export sitemap.

Is this likley to continue for the forseeable future?

By some experimenting I have changed by regex to:
(?<=weight ).+(?= kg)

which solves my initial problem.

I would still like to know about the long term support for regex.

how about this rule:
[\d.]+

1 Like