This is for PHP preg_match code - which is PCRE therefore looking for a perl compatible suggestion
I have this line returned I want to match and return..
[awk -F, '(NR==2) {print $3"ABCXYZ"}' portfolio-hierarchy .csv RootABCXYZ ^dg@torpsbe1\[1mClient_Source/20140403%
I want to match the two instances of string ending 'ABCXYZ' into an array.
And on second element (ie. RootABCXYZ) only return the word "Root"..
Thanks in advance
What will the actual record you want to scan look like?
the record is as such, i just need something that works theoretically for such, that finds the two instances of ABCD, but extract the `Root` out of ABCD......
[awk -F, '(NR==2) {print $3"ABCXYZ"}' portfolio-hierarchy .csv RootABCXYZ ^dg@torpsbe1\[1mClient_Source/20140403%
---------- Post updated at 09:45 PM ---------- Previous update was at 09:44 PM ----------
i mean ABCXYZ
Try this to return the value before the 2nd "ABCXYZ":
csv (.*)ABCXYZ
Match the characters "csv " literally
Match the regular expression below and capture its match into backreference number 1
Match any single character that is not a line break character
Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match the characters "ABCXYZ" literally
$result = preg_replace('/csv (.*)ABCXYZ/im', '$1', $subject);
Unfortunately that one is not working..
why isn't this one working either? Do you see something fundamentally wrong?
$test = "[0mawk -F, '(NR==2) {print $3"ABCXYZ"}' portfolio-hierarchy .csv RootABCXYZ ^presales@torpsbe1\[1mClient_Source/20140403%";
preg_match('#.csv (.*?)ABCXYZ#', $test, $matches);
echo "</br>";
echo $matches[0];
echo "</br>";
echo $matches[1];
result:
(nothing)
(nothing)