Sentences starting with “I wish” or “If only” express wishes or regret. If only is slightly more formal and gives the wish or regret more emphasis.
If only I hadn’t eaten so much soup. I feel awful! (strong regret)
I wish / If only + past simple
This structure is used to say that we would like something to be different from what it is in the present. It can also be used with people.
If only my wife earned more money.
I wish John was / were here.
I wish / If only + past perfect
This structure is used to express regrets about the past / a wish that something in the past had happened differently. It can be used with people:
If only you had told me sooner.
I wish they had gone by train.