Last active
February 16, 2017 05:29
-
-
Save ritalin/ba4461aeb8cc9ea286e487b5b2003e4a to your computer and use it in GitHub Desktop.
与えられた文字列中に含まれる単語の個数を単語ごとにカウントする for Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$s = "I have a pen. I have a apple. oh!! Apple pen! I have a pen. I have a pineapple. oh!! Pineapple pen! Apple pen. Pineapplepen. Pen pineapple apple pen." | |
$s -split(' ') | ?{ $_ -match "(\w+)[^.!]?" } | %{ $matches[1] } | group | select -Property Name,CountName | |
# Name Count | |
# ---- ----- | |
# I 4 | |
# have 4 | |
# a 4 | |
# pen 7 | |
# apple 4 | |
# oh 2 | |
# pineapple 3 | |
# Pineapplepen 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment