How to group within a group using Perl's regex?
Posted on 2011-02-21
I have the following line of code if(/^\@([^\n]*).*(^1\.[^\n]*)/ms) below that needs further grouping for the second group
open FH, '<', 'dd' or die $!;
For example, I have the following data record. I would like to capture the whole number line in which this code does this (^1\.[^\n]*) but I also would like to subcapture the (dkdkdkd-) leading to the hyphen so I can color code it using the html color tag.
1. dkdkdkd- dldldldldldldldl
My way was to do the following (see below) but this does not work because it also captures the other lines after line number 1.