Solved

Regex Select user names with X.

Posted on 2014-12-01
8
125 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 40

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 84

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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