Search string position in a line

WeeksD1|$26.52|$26.52|03/02/2013|12.48|D1|1.09|0|0|0|0|0|.95|0|0|0|0|0|0|0|0|0|0|0|0|0|0||$0.00|$0.00||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||$0.00|$0.00||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||$0.00|$0.00||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|G4|$12.24|$0.00|$0.00|$0.00|$0.00|$12.24|T1|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|$0.00|M1 

i used the following command :

awk -v a="$lineInput" -v b="D1" 'BEGIN{print index(a,b)}'

need to find " |D1| " string .. how can i use the pipe in the search .

Thanks
Mani

awk -F\| '{ for(i=1;i<=NF;i++) { if($i=="D1") print $i,i; } }' infile

Note: File: infile contains the pipe separated data.

try also:

awk -v a="$lineInput" -v b="D1" 'BEGIN {print index(a, "|" b "|")}'

or

echo "$lineInput" | awk -v b="D1" '{print index($0, "|" b "|")}'
awk -v a="$lineInput" -v b="|D1|" 'BEGIN{print index(a,b)}'