Replace the string instance with the Replace operator in PowerShell _powershell

Source: Internet
Author: User

This article describes the string substitution operator in PowerShell: Replace. In Replace, you can use regular expressions, which greatly improves the functionality of replace.

Copy Code code as follows:

Ps> ' unit1,unit2,unit3 '-replace ' [, T] ', '; '
Unit1; Unit2; Unit3

The above example uses a comma (,) or tab (\ t) from the given string to replace the component number (;). This is a very common application that is often needed to construct a CSV file. A CSV file is a semicolon-delimited data for each cell.

The use of the replace operator is:

Copy Code code as follows:

< pending strings >-replace < find character >,< replacement character >

Explain the meaning of this grammar, which is to find the < lookup character in the < pending string >, and replace the < lookup character > with the < replacement character >. Here,< find characters > You can use regular expressions. Finding a match through a regular expression will greatly enhance the function of the replace operator.

About the use of Replace operator and regular expression in PowerShell, this article introduces so many, hope to help you, thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.