You can also do it without negative look ahead. You just need to add parentheses to that part of expression which you want to extract. This construction with parentheses is named group
.
Let's write python code:
string = """OK SYS 10 LEN 20 12 43
1233a.fdads.txt,23 /data/a11134/a.txt
3232b.ddsss.txt,32 /data/d13f11/b.txt
3452d.dsasa.txt,1234 /data/c13af4/f.txt
.
"""
search_result = re.search(r"^OK.*\n((.|\s)*).", string)
if search_result:
print(search_result.group(1))
Output is:
1233a.fdads.txt,23 /data/a11134/a.txt
3232b.ddsss.txt,32 /data/d13f11/b.txt
3452d.dsasa.txt,1234 /data/c13af4/f.txt
^OK.*\n
will find first line with OK statement, but we don't want to extract it so leave it without parentheses. Next is part which we want to capture: ((.|\s)*)
, so put it inside parentheses. And in the end of regexp we look for a dot .
, but we also don't want to capture it.
P.S: I find this answer is super helpful to understand power of groups. https://stackoverflow.com/a/3513858/4333811