I would like to check for 2 patterns across a piece of text (a total of 4 delimiters).
Either one of the two patterns matches is fine. However when they qualify, I would like the results to be next to each other side by side.
This is the INPUT TEXT (it contains two separate long lines. Actual input text is much more. I have chosen relevent snippets as shown below):
Query Response #5: [2659] ID,(0010,0030) DA #8 [19801024] PatientÆs Birth Date,,,(0020,000D) UI #42 Station Title,,,>(0040,0002) DA #8 [20301212] Scheduled Procedure Step Start Date,,,>(0040,0003) TM #4Information
Query Response #6: ID, (0010,0030) DA #8 [19410203] PatientÆs Birth Date, Title,,,>(0040,0002) DA #8 [20210826] Scheduled Procedure Step Start Date, FIND]
This is the DESIRED OUTPUT:
19801024 20301212
19410203 20210826
There are 2 pairs of delimiters. The 1st set of delimiters is this:
(0010,0030) DA #8 [
] Patient
The 2nd set of delimiters is this:
(0040,0002) DA #8 [
] Scheduled Procedure Step Start Date
I am able to apply each pair of delimiter by itself. Specifically, when I do this:
grep -o -P "(?<=0010,0030\) DA #8 \[).*(?=\] Patient)"
I get this output:
19801024
19410203
When I apply this 2nd pair of delimiter like this below:
grep -o -P "(?<=0040,0002\) DA #8 \[).*(?=\] Scheduled Procedure Step Start Date)"
I get this output:
20301212
20210826
How do I issue a correct combined grep command such that the output result is as shown below? :
19801024 20301212
19410203 20210826
I tried this following approach without success:
grep -e "(?<=0040,0002\) DA #8 \[).*(?=\] Scheduled Procedure Step Start Date)" -e "(?<=0010,0030\) DA #8 \[).*(?=\] Patient)"
The error message I get is follows:
grep: Unmatched ) or \)
Thanks in advance. I hope my question is clear. (Please note I'm using grep under Windows10. The outer quatations marks have to be double quotation marks)