正则表达式提取短匹配[关闭]

I am new to regular expression.

The contents is

">blablabla</a> </td>blablabla "> 8.8GB </a> </td>

I want to get the value 8.8, but if i use (?<=">)(.*?)(?=GB<\/a>), it will get the texts before 8.8 as well, ie. ">blablabla</a> </td>blablabla "> 8.8GB

I don't know how to solve this. Any help is much appreciated.

You could use:

(\d+(?:\.\d+)?)[MKG]B

to extract the integer value before the storage unit.

The \d is any number.
+ is a quantifier allowing 1 or more numbers.
?: is a non-capturing group.
\. is a literal ..
? makes the decimal part (\.\d+) optional.
[MKG] is a character class allowing M, K, or G. B is a literal B.

Demo: https://regex101.com/r/3TifGy/1

PHP Usage:

<?php
preg_match('/(\d+(?:\.\d+)?)[MKG]B/', '">blablabla</a> </td>blablabla "> 8.8GB </a> </td>', $match);
echo $match[1];

PHP Demo: https://eval.in/656562