Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Regex Select user names with X.

Posted on 2014-12-01
8
Medium Priority
?
129 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
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.

 
LVL 41

Assisted Solution

by:footech
footech earned 1000 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 1000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…

715 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