Consider a log file which contains
r100000|Tom Sawyer|2010-12-01|view.txt
I should parse this and print
ID:r100000
NAME:Tom Sawyer
DATE:2010-12-01
FILENAME:view.txt
I should only use regular expressions.
the easier way is to break your string into fields, using delimiters. Since you have pipe "|" as delimiters, then use it. No need for complicated regex. Plus, what if you have more fields next time?.
Here's one with awk (you can use -F option of Perl as well)
$ awk -F"|" '{print "ID:"$1" Name:"$2" Date:"$3" filename:"$4}' file
ID:r100000 Name:Tom Sawyer Date:2010-12-01 filename:view.txt
Perl equivalent
$ perl -F"\|" -ane 'print "ID:$F[1] Name: $F[2] Date:$F[3] filename:$F[4]"' file
ID:Tom Sawyer Name: 2010-12-01 Date:view.txt