Image Source: Getty Images.

In a surprising development, the U.K. voted to leave the European Union, despite earlier indications to the contrary. This caused stock markets all over the world to tumble, and the banking sector was hit particularly hard. It makes sense: A British exit could mean weaker activity in the capital markets, and lots of U.S. banks have substantial exposure to the U.K.

However, now isn't the time to panic. Here's why you should view this as a buying opportunity for Goldman Sachs (GS -0.71%), New York Community Bancorp (NYCB 0.33%), and Wells Fargo (WFC -1.11%).

Wall Street's "best and brightest" are getting clobbered

Goldman Sachs gets about one-fifth of its revenue from its British operations, so it's no surprise that it's getting beaten down by the Brexit vote.

Shortly before the vote took place, Goldman sent a note to its clients saying that a Brexit wouldn't be as detrimental to stocks as the Lehman Brothers collapse, as many experts have feared. After the vote took place, Goldman CEO Lloyd Blankfein said Goldman had planned for either outcome many months in advance, saying that Goldman respects the decision of the British electorate.

"Goldman Sachs has a long history of adapting to change," Blankfein went on to say in his statement. "Our primary focus, as always, remains serving our clients' needs."

While it's understandable for the stock to take a hit, I'm still highly optimistic about Goldman's long-term potential. And Goldman's deeply discounted share price more than makes up for any Brexit concerns: Goldman now trades for 14% less than the value of its tangible assets -- a rock-bottom valuation for Goldman.

GS Price to Tangible Book Value Chart

This expanding bank was already on sale

Down by about 5% after the Brexit vote, New York Community Bancorp was already on sale. And while there could be some foreign exchange risk or other pressure on NYCB, as a regional bank, it doesn't have much exposure to the U.K., so I look at this price drop as a fortunate discount and nothing more.

NYCB is a niche lender, primarily focused on rent-controlled New York City multifamily properties, and this has worked well for the bank and its shareholders. Rent-controlled buildings have little risk of default and are virtually recession-proof, which has led to some of the industry's lowest loan charge-off rates, even during the toughest times.

Source: NYCB company presentation. 

Because these types of loans are cheaper to originate and service than traditional mortgages, NYCB has been able to operate at a level of efficiency that would make most other banks jealous.

The problem is that the bank's pending merger with Astoria Financial (AF) isn't viewed as a positive development by many shareholders. For one thing, the merger will boost NYCB's assets well over the $50 billion threshold it has been actively avoiding for years. This means NYCB will be considered a "systemically important financial institution," and thus it will have to spend a lot of money to meet regulatory standards. On top of that, Astoria isn't nearly as efficient as NYCB, and there is legitimate concern that NYCB's main competitive advantage could begin to erode.

However, keep in mind that NYCB's management has done a fantastic job of producing consistent, above-average returns for a long time -- and I have faith in their plans going forward.

Even the most solid banks aren't immune

Wells Fargo is widely regarded as one of the most rock-solid banks in the market, but even it couldn't escape the Brexit panic.

Low interest rates have kept profit margins low at Wells Fargo (and other banks), and its exposure to energy lending has been a cause for concern, but Wells Fargo is still delivering some of the best levels of profitability in the banking industry.

WFC Return on Equity (TTM) Chart

Wells doesn't have the British exposure of the other big U.S. banks. In fact, Scott Wren, a Wells Fargo senior global equity strategist, said a few days before the vote that an exit vote would be a tremendous buying opportunity in large-cap U.S. stocks. He went on to say that there will be some noise and volatility, but once that subsides, people will wish they had bought during the panic.

Although Wren wasn't talking specifically about his own company's stock, his advice still applies. For investors who don't quite have the risk tolerance for the other two stocks I mentioned here, Wells Fargo is about as solid a banking stock as you can find -- and now it's on sale, thanks to the Brexit.

The bottom line on the Brexit vote

When an event like this happens, the best thing to do is take a deep breath, step back, and consider the big picture. The Brexit vote isn't the worst thing U.S. markets have been through -- not even close. Nor will it be the last development to cause a short-term stock market plunge.

Over the long run, solid stock investments make money despite events like this. Sure, the U.S. stock market fell by 38% in 2008 in the midst of the financial crisis, but it has gained 127% since. So, when the market does crash, don't look at it as a reason to panic. Rather, think of it as a major sale at your favorite store and start looking for the best bargains available.