"^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4})|((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{5})|((\+44\s?\d{5}|\(?0\d{5}\)?)\s?\d{5})|((\+44\s?\d{5}|\(?0\d{5}\)?)\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$";
我使用上述模式来验证英国电话号码。它在 JavaScript(客户端)中工作。但它不适用于 Java 代码(服务器端)。错误消息说invalid escape sequence
。