$sentence = "A~~~one~A and A~~~two~A"; $sentence =~ m/A~~~(.*)~A/g; print $1;