Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to hide 4 digits in the middle of mobile phone number by using regular expression

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to use regular expressions to hide 4 digits in the middle of your mobile phone number. the content is concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Hide the middle four digits of the mobile phone number and become 186 million digits and 9877 digits.

/ * * Hidden some mobile phone numbers * @ param phone * @ return * / public static String hidePhoneNum (String phone) {String result = "; if (phone! = null & &!" .equals (phone)) {if (isMobileNum (phone)) {result = phone.substring (0,3) + "*" + phone.substring (7);}} return result;}

two。 Determine whether it is a mobile phone number.

/ * check whether it is a phone number * * @ return * / public static boolean isMobileNum (String mobiles) {Pattern p = Pattern. Compile ("^ ((13 [0-9]) | (14 [0-9]) | (15 [^ 4,\\ D]) | (18 [0-9])\\ d {8} $"); Matcher m = p.matcher (mobiles); return m.matches () } the above content is how to use regular expressions to hide the four digits in the middle of the mobile phone number. have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report