-1

I get a large compilation output from my IDE when I do a batch build over my complete workspace. For every single projekt it contains a line like this:

foo.elf - x error(s), y warning(s)

I want to finde every instance where the numer of errors differs from 0. I do get a slightly prommising result with:

[1-9]+ +error

but this fails for every instance where the number of errors is evenly divisible by 10 like here

foo.elf - 20 error(s), y warning(s)
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
EN20
  • 51
  • 11

1 Answers1

0

May be something like [1-9][0-9]*(?= error)

Example (Written in python)

items =['x error' , '20 error','0 error','15 error','40 error','4 error','456 error' ] 
for item in items:
    print(re.findall(r'[1-9][0-9]*(?= error)',item))

Output

[]
['20']
[]
['15']
['40']
['4']
['456']
moys
  • 7,747
  • 2
  • 11
  • 42
  • [1-9][0-9]*\s+error – Alex Sveshnikov Feb 26 '20 at 08:04
  • @Alex Thanks. Yes `*` works better. In your code, we get the word `error` also as match. I tried to match only the digits. – moys Feb 26 '20 at 08:09
  • Since this compiler stops anyway after I belive 256 errors this works like a charm and it is easy scalable to the number of digits needed. I am curious though if there is a way to not have to account for the possible number of digits. – EN20 Feb 26 '20 at 08:11
  • See the latest code. This will work irrespective of number of digits. – moys Feb 26 '20 at 08:12
  • Either of the solutions are fine sine my overall goal is to see with one search that no match was fount so I can be shure everything compiled without errors – EN20 Feb 26 '20 at 08:16