I Need to extract digits before a full stop.
Sample Text
REFERENCE DATE DOC.NUM INV.AMOUNT DED INV.AMOUNT.
91300730 20211018 2151229942 1367579.73 0.00 -1367579.73.
.
91300622 20211013 2151226915 167554.96 0.00 167554.96.
.
91300608 20211013 2151226910 1367579.73 0.00 1367579.73.
.
91300621 20211013 2151226909 729375.52 0.00 729375.52.
expected output is : -1367579.73., 167554.96., 1367579.73. and 729375.52..
CodePudding user response:
Assuming we can identify a full stop as being a period either followed a newline or the end of the input, we can try:
-?\d (?:\.\d )?(?=\.(?:\n|$))
Demo
This says to match:
-? optional negative sign
\d a whole number
(?:\.\d )? followed by an optional decimal component
(?=\.(?:\n|$)) followed by dot, then a newline or end of the input
CodePudding user response:
This should get you started:
/\s(-*[0-9\.]*)\.\s/
