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 match [0100] with C #

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to match [0,100] with C#". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to match [0,100] with C#" together!

Here's a comprehensive example. Special considerations for matching [0,100] include

00 legal, 00. legal, 00.00 legal, 001.100 legal

Empty string is illegal. Decimal point only is illegal. More than 100 is illegal.

Numeric values can be suffixed, e.g."1.07f" indicates that the value is a float type (not considered)

C#regular expression pair [0,100] matching application example:

Regex r = new Regex(@"^\+? 0*(?: 100(\.0*)?| (\d{0,2}( ?=\.\ d)|\d{1,2}(?= ($|\.$))) (\.\ d*)?)$ "); string x = ""; while (true) { x = Console.ReadLine(); if (x != "exit") { if (r.IsMatch(x)) { Console.WriteLine(x + " succeed! "); } else { Console.WriteLine(x + " failed! "); } } else { break; } } Thank you for reading, the above is the content of" how to match [0,100] with C#", after learning this article, I believe everyone has a deeper understanding of how to match [0,100] with C#, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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

Development

Wechat

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

12
Report