PowerShell tips to determine whether to cover the case _powershell

Source: Internet
Author: User
Tags lowercase uppercase letter

You can use regular expressions to check whether one character contains one uppercase letter:

$text 1 = ' This is the all lower-case '
$text 2 = ' lower-case ', ' Not all '
 
$text 1-cmatch ' [A-z] '
$text 2-cmatch ' [A-z] '

The result returns "true" or "false"

In turn, check to see if it contains lowercase, and you can try this:

$text 1 = ' This are all lower-case '
$text 2 = ' This is ' lower-case '

$text 1-cmatch ' ^[a-z\s-]*$ '
$text 2-c Match ' ^[a-z\s-]*$ ' 

The result returns "true" or "false"

Overall, this test is more difficult because you need to consider the legality of all characters. In this example, I used a lowercase string from A to Z, a space and a minus sign.

A valid string is embedded in the middle of "^" and "$" (it represents the start and end of a line). The asterisk represents quantifying any preceding legitimate strings.

Supports all PS versions

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.