javaregexdecimalbracketstasker

Simple regex between brackets


Sorry for being a noob but I have been searching the forums for hours but no luck so huge thanks if you can help.

I'm using Tasker which I believe uses a java flavor of regex.

I have random data for example: blah blah blah 6521 (3.2g) 345 (8g) 34 etc...

Between the brackets there's only ever a just a single digit or a single digit followed by a single decimal digit, with the ( and g) always being constant, I simply need to extract numbers like:

3.2 & 8 into their array which Tasker will do.

What I would think should work, is not working properly:

\d+.\d+|\d+

It produces all the numbers instead of just those between ( and g)

Any pointers anyone?

Much appreciated all!

EDIT:typos


Solution

  • Please try the following pattern: (?<=\()\d+\.?\d?(?=g\))

    Online Demo