How can I remove or replace string

for example

$string= 222111.pdf

i want string be(remove or replace .pdf with .txt)

222111.txt

??