Thanks for reaching out to EmpowHER!
What you have described is dry sex which can not cause pregnancy. Pregnancy can only occur with vaginal intercourse and penetration.
That's a good sign that your girlfriend had 2 regular periods. I wouldn't think there is a chance of pregnancy in your situation, but the only way to know for sure is by taking a pregnancy test. Seeing a negative test can help ease some fears too.
Take a look at this article to get a better idea of dry sex and common myths around it and pregnancy: https://www.empowher.com/community/share/outercourse-dry-humping-dry-sex...