Match, but don't include the result with regex

I am trying to match a group in a regular expression, but I do not want this group to be the end result.

For instance:

((kl(\.)?|at)? ([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)

Running the above expression on at 12:25should return 12:25.

Is there any way to do this?

I tried using:

(?:((kl(\.)?|at)? )([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)

But there is no difference.

Then i tried

(?<!(?:((kl(\.)?|at)? )([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)

But this returned an empty result.

I use an expression in C #.

+5
source share
1 answer

A non-exciting group (not found in matching groups) is designated as (? :) . In this way,

(?:(?:kl(?:\.)?|at)?([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?)

But you regexp seems to be erroneously structured from the start. You do not record minutes.

+9
source

All Articles