I'm struggling to write a proper regexp to use with PHP7.4 to extract required information from a string.
Here are the sample strings:
Numer właściciela: NOWAKOWSKA 01-234 Warsaw
Numer właściciela: NOWAK_S6_2
Numer właściciela: KOWALSKA_S6_ 01-234 Warsaw
Numer właściciela: NOWACKI S6_ 01-234 Warsaw
What I want to extract is accordingly:
NOWAKOWSKA
NOWAK_S6_2
KOWALSKA_S6_
NOWACKI S6_
So far I was using the %^Numer właściciela:[[:space:]](?<owner_id>.+)$%imu
which worked fine (with example from row#2). However, turns out that the other cases (#1, #3, #4) appeared during a roll-out phase and our text extraction is not accurate enough.
The problem here is with spaces, the source text may contain space inside the pattern and this space must be included in the result. However, if there are repeating spaces, they must not be included.
Tried playing around with some conditionals and negative lookaheads to exclude multiple spaces, but failed to do so.
Would really appreciate any help here.