Carol.Kar
Carol.Kar

Reputation: 5355

Match numbers with

I am having the following list of numbers which I would like to match:

44Th/s
40ksol/s
76Th/s
40Th/s
485Mh/s
432Mh/s
7Th/s
365Mh/s
33Th/s
3.1Th/s
6Th/s
1.1Gh/s
2.4Th/s
1.155Th/s
112.155Gh/s

I am using =regexreplace(A2,"[^\d]","") to match the numbers part. However, when a number looks like that 1.155Th/s I get back 1155.

enter image description here

I also tried the following regex \d*[.]\d*, which only gives me back:

 3.1
 1.1
 24
1.155
112.155

Any suggestions how to also get the numbers part that looks like that 1.155, 112.155 or 3.1?

I appreciate your replies!

Upvotes: 3

Views: 67

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627126

I suggest extracting the float/int value using REGEXEXTRACT:

=REGEXEXTRACT(A24, "\d+(?:\.\d+)?")

This will extract the first occurrence of a substring that starts with 1+ digits and is followed with an optional sequence of . and then 1+ digits.

enter image description here

Upvotes: 2

Related Questions