 -- Republican officials are exploring how to handle a scenario that would be unthinkable in a normal election year: What would happen if the party's presidential nominee dropped out?

ABC News has learned that senior party officials are so frustrated — and confused — by Donald Trump's erratic behavior that they are exploring how to replace him on the ballot if he drops out.

So how would it work?

First, Trump would have to voluntarily exit the race. Officials say there is no mechanism for forcing him to withdraw his nomination. (Trump has not given any indications that he no longer wants to be his party's nominee.)

Then it would be up to the 168 members of the Republican National Committee to choose a successor, though the process is complicated.

One Republican legal expert has advised party officials that, for practical reasons, Trump would have to drop out by early September to give the party enough time to choose his replacement and get the next nominee's name on the ballot in enough states to win.

Here is what the RNC's bylaws say about filling a vacancy on a presidential ticket:

Rule No. 9: Filling Vacancies in Nominations

(a) The Republican National Committee is hereby authorized and empowered to fill any and all vacancies which may occur by reason of death, declination or otherwise of the Republican candidate for president of the United States or the Republican candidate for vice president of the United States, as nominated by the national convention, or the Republican National Committee may reconvene the national convention for the purpose of filling any such vacancies.

(b) In voting under this rule, the Republican National Committee members representing any state shall be entitled to cast the same number of votes as said state was entitled to cast at the national convention.

(c) In the event that the members of the Republican National Committee from any state shall not be in agreement in the casting of votes hereunder, the votes of such state shall be divided equally, including fractional votes, among the members of the Republican National Committee present or voting by proxy.

(d) No candidate shall be chosen to fill any such vacancy except upon receiving a majority of the votes entitled to be cast in the election.