Regex Help

I hope someone can please help me with this, I need to extract the amount after the @:

Here is the Text:

SOLD 1 HG Jul’23 @COMEX @ 3.84 (UXXX34370) as of 2023-05-10 21:30:42.
Message Reference Number: 2-1683768643020-572449, Sent Date: 2023.05.10 21:30:43 -0400

Hi @Sam_Krausz

It depends a bit on how stable the structure of the text is (meaning how likely some portions of the text are going to change).

Assuming the (UXXX) part maybe refers to a user or transaction and XXX refers to masked characters, we could reason that (UXXX will always be in this format and will always follow the amount you want to extract).

With that assumption, the following regex could work:


Basically we’re looking for a series of non-space characters, followed by one space and (UXX. The space and (UXX are excluded from the match result via the positive lookahead (?= )

You can try it out yourself online:


Thank you very much

P.S. I remind myself that for next time I can ask ChatGPT, and here is their respond:


Good that you thought of chatGPT!

glad to have helped!

1 Like