Solved

Regex Select user names with X.

Posted on 2014-12-01
8
124 Views
Last Modified: 2014-12-01
User names consist of a-z upper and lower case followed by 6 digits. Example. A123456 or B459087 or U997345.
I have a list that contains other names like Administrator or JoeSmith other than the users names above.
I would like to only see the User names "[a-z]123456".
0
Comment
Question by:Xytras1
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40474059
What is your question?
0
 

Author Comment

by:Xytras1
ID: 40474068
Opps should of said a little more.

I have a List of User names  that consist of a-z upper and lower case followed by 6 digits. Example. A123456 or B459087 or U997345. Also the list that contains other names like Administrator or JoeSmith other than the users names above.
I would like to only see the User names "[a-z]123456".
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40474074
I still don't see a question   : \

Are you asking what the pattern that would match the above should be, or are you asking how to do a regex search in PowerShell, or are you asking something else?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 39

Assisted Solution

by:footech
footech earned 250 total points
ID: 40474078
Perhaps you're trying to read from a file and want to only display names that match your criteria?
get-content file.txt | Where { $_ -match "[a-z][0-9]{6}" }

Open in new window

0
 

Author Comment

by:Xytras1
ID: 40474081
This should help with my poor English sorry.

$OldList =  "A123456, B459087, U997345, JoeSmith, Administrator"

$NewList = "A123456, B459087, U997345"

Trying to filter out non standard user names.
0
 

Author Comment

by:Xytras1
ID: 40474091
footech.

get-content file.txt | Where { $_ -match "[a-z][0-9]{6}" }

Is pretty close. Any way to make it match exactly?
Getting some false positives like "CPAOLAM3334988"
0
 
LVL 83

Accepted Solution

by:
oBdA earned 250 total points
ID: 40474109
You need to anchor the match: "^[a-z]\d{6}$"
0
 

Author Closing Comment

by:Xytras1
ID: 40474117
"^[a-z]\d{6}$" Works. Thank you.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Set OWA language and time zone in Exchange for individuals, all users or per database.
This article will help you understand what HashTables are and how to use them in PowerShell.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question