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 the simple Application of looking around in regular expressions based on java

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly shows you "based on java how to achieve the regular expression in the simple application of look", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "based on java how to achieve the regular expression in the simple application of look" this article.

The details are as follows:

Because the development work needs to filter the content in the text, delete or replace some useless or unqualified information. As a result, it is found that many units with the same English writing but different meanings are used in a certain kind of engineering text, which need to be converted into Chinese characters corresponding to the real meaning. For example: "the viscosity is 17s and the moving distance is 350cm, which requires that the concrete must be light inside and outside. The vibration time is 30s." It is obvious that the first s is the unit of viscosity and the second s is the unit of time. Now you need to replace all the s representing time in the text with "seconds". Under the guidance of a friend, you can easily achieve this function by looking around in regular expressions.

It is generally accepted that the basic principle of looking around in regular expressions is to match according to the location information. I think it can also be understood as matching according to the context of the target character.

The specific Java code is as follows

Package ccnu;import java.util.regex.Matcher;import java.util.regex.Pattern;import java.util.regex.PatternSyntaxException;public class regex {/ * * @ param args * / public static void main (String [] args) {/ / TODO Auto-generated method stub String tempHtmlString= "viscosity is 17s, moving distance is 350cm, concrete must be light inside and outside. Vibrating time is 30s." ; Pattern pumped html; Matcher massively html; String regEx = "([^ viscosity] [u4e00-u9fa5] {1Magne 10} (?

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