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 realize a character fuzzy matching function by using regular expression

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

Share

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

This article introduces you how to use regular expressions to achieve a character fuzzy matching function, the content is very detailed, interested friends can refer to, hope to be helpful to you.

The details are as follows:

Package com.cn.util;import java.util.regex.Pattern / * regular expression tool class * * @ author lifangyu * / public class RegexUtil {/ * * IP address matching markup (/ /\ d {1jue 3}) /:\ d / / 0q9 digits, at least one digit, up to three digits) * / private static String regex_IP = "^ (121.15.215. (\\ d {1mer3})) $" / * * string fuzzy matching: ^ (. * Zhang San. * name.*) $; equivalent match ^ (Zhang San) $* / private static String regex_containStr = "^ (. * Zhang San. * name.*) $"; / * * expressions with characters that do not contain specific strings * / private static String regex_notcontainStr = "^ (?!. * (forwarding). * $" / / expression public static void main (String [] args) {System.out.println (StringMatchRule ("this email is forwarded!") that does not contain a specific string. , regex_notcontainStr);} public static boolean StringMatchRule (String souce, String regex) {boolean result = false; if (regex! = null & & souce! = null) {result = Pattern.matches (regex, souce);} return result;}} on how to use regular expressions to achieve a character fuzzy matching function is shared here. I hope the above can be helpful and learn more. If you think the article is good, you can share it for more people to see.

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