-1

I am trying to read the value

Colli 182515612/OT 37/SA

The only value I'll need is 182515612. Since there are multiple 9 digits numbers found in the file I need the regex to look for Colli and then just separate the 9 digit value after that from everything else.

I have tried [^colli ](\d{9}) and [colli ][0-9]{9} The second one seems to at least read out the value however it seems to just look for the numbers with an empty space in front of it, so it might read out other values as well.

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223

2 Answers2

0

This regex:

^Colli+\s+\K\b\d{9}

online demo

The regular expression matches as follows:

Node Explanation
^ the beginning of the string
Colli Colli
\s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible))
\K resets the start of the match (what is Kept) as a shorter alternative to using a look-behind assertion: look arounds and Support of K in regex
\b the boundary between a word char (\w) and something that is not a word char
\d{9} digits (0-9) (9 times)
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
0

Try:

(?<=Colli )\d{9}

Regex demo.


This matches 9 digits that are preceded with string "Colli "

Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91