0

I'm working on learning how to use regular expressions, and have found a conversion that has me stuck.

Given the statements:

1. pi=3.14 and pie

2. pie and pi=3.14

How do I match pi and turn it in to 3.14 without also catching pie? This is user input, so I can't rely on position in the string.

My attempt was:

s/pi\W/3.14/g

That almost worked, but the \W ate the equals sign so I got:

3.143.14 and pie

Thanks in advance for any help. (This is not homework, but it is school related.)