Solved

Regex Select user names with X.

Posted on 2014-12-01
8
128 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Are You Headed to Black Hat USA 2017?

Getting ready for Black Hat next week? Kick things off with the WatchGuard Badge Challenge and test your puzzle and cipher skills. Do you have what it takes to earn our limited edition Firebox Badge? Get started today - https://crimsonthorn.net

 
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 85

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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