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 replace a string with regular expressions

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

Share

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

This article is about how to use regular expressions to replace strings. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

I have the following lines:

D:\ Projects\ qqq\ Development\ qqq.MySol1.sln

D:\ Projects\ qqq\ qqqDevelopment\ qqqMySol2.sln

D:\ Projects\ qqq\ Development\ MyInstaller.sln

D:\ Projects\ qqq\ qqq\ Development\ MyInstaller.sln

D:\ Projects\ Development\ MyInstaller.sln

I need a regular expression, which will result in capturing:

Line 1: Development and MySol1.sln

Line 2: Development and MySol2.sln

Line 3: Development and MyInstaller.sln

Line 4: Development and MyInstaller.sln

Line 5: Development and MyInstaller.sln

Therefore, a regular expression will delete (ignore) the word qqq from the line. I have been trying to adjust with, and have part of the solution:

The copy code is as follows:

. * (?. *). {3} (?. *)

This leads to:

Line 1: Development and .MySol1.sln

Line 2: qqqDevelopment and MySol2.sln

Line 3: Development and nstaller.sln

Line 4: Development and nstaller.sln

Line 5: Development and nstaller.sln

Therefore, {3} should be fixed.

1. I think we should work:

. *\ (?: qqq)? (?. *)\ (?: qqq)? (?. *)

The above is how to replace strings with regular expressions. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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