Click here to Skip to main content
16,015,351 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
Questionregex code assistance for entering 600 in a input field Pin
Member 1568365422-Jun-22 4:13
Member 1568365422-Jun-22 4:13 
QuestionRe: regex code assistance for entering 600 in a input field Pin
Richard MacCutchan22-Jun-22 5:39
mveRichard MacCutchan22-Jun-22 5:39 
AnswerRe: regex code assistance for entering 600 in a input field Pin
Member 1568365422-Jun-22 6:08
Member 1568365422-Jun-22 6:08 
GeneralRe: regex code assistance for entering 600 in a input field Pin
Richard MacCutchan22-Jun-22 6:49
mveRichard MacCutchan22-Jun-22 6:49 
GeneralRe: regex code assistance for entering 600 in a input field Pin
Member 1568365422-Jun-22 6:58
Member 1568365422-Jun-22 6:58 
GeneralRe: regex code assistance for entering 600 in a input field Pin
Richard Deeming22-Jun-22 21:52
mveRichard Deeming22-Jun-22 21:52 
GeneralRe: regex code assistance for entering 600 in a input field Pin
Richard MacCutchan22-Jun-22 22:08
mveRichard MacCutchan22-Jun-22 22:08 
QuestionPattern Check Match Pin
Member 1567083112-Jun-22 4:17
Member 1567083112-Jun-22 4:17 
Friends,
I am using PowerShell.
I am trying to write a regex match pattern for a string that has ALL these qualifications:
1. Must have one and only one period in the string.
A. At least one Alpha, A-Za-z before the period.
B. At least one Alpha, A-Z Za-z after the period.
2. The last character in the string must be numeric, 0-9 No Alpha, A-Za-z
3. The second-to-the-last character must be one of these two:
A. May be Alpha, , A-Z Za-z or
B. May be numeric, 0-9
4. No Numerics, 0-9 Allowed except the last two characters in the string.

Examples of good ones:
Joe.Jones1
Joe.Jones01
J.J1
j.j99
jo.jn01
jo.j1

I have written many small pieces of code that could be pieced together using -AND for many matches but surely there is a way to make some one-liner that can incorporate all of these.
I may be able to do it using -AND like this:
$test -notmatch “[0-9]” -AND $test -NOTmatch “[\.]" -AND $test -match “[a-zA-Z]" -AND $test -NOTmatch “[@#$%^&*()]"

But I would like to be eloquent and do something like this:
$GoodPatternCheck = $PossibleGoodName -match '.+,.+,.+,.+'
If ( $GoodPatternCheck )

I have written many short matches in my learning process which I plan on sharing with my co-workers who are also novices.
I don't see any way to attach a file here, so here is an example of the kinds of short piece of code I write and test to help me learn:
$test = "Now......... is t.he, tim,e"
Write-Host ‘$test’ $test
$Count = ($test.Split('\.')).count -1
Write-Host ‘$test’ $test
Write-Host ‘$Count’ $Count


Thank you in advance for your help on this.

-- modified 12-Jun-22 10:58am.
AnswerRe: Pattern Check Match Pin
Peter_in_278012-Jun-22 5:05
professionalPeter_in_278012-Jun-22 5:05 
GeneralRe: Pattern Check Match Pin
Member 1567083112-Jun-22 6:22
Member 1567083112-Jun-22 6:22 
AnswerRe: Pattern Check Match Pin
OriginalGriff12-Jun-22 6:23
mveOriginalGriff12-Jun-22 6:23 
GeneralRe: Pattern Check Match Pin
Member 1567083112-Jun-22 7:38
Member 1567083112-Jun-22 7:38 
GeneralRe: Pattern Check Match Pin
Member 1567083112-Jun-22 8:13
Member 1567083112-Jun-22 8:13 
GeneralRe: Pattern Check Match Pin
Member 1567083112-Jun-22 7:32
Member 1567083112-Jun-22 7:32 
GeneralRe: Pattern Check Match Pin
Member 1567083112-Jun-22 11:49
Member 1567083112-Jun-22 11:49 
AnswerRe: Pattern Check Match Pin
Peter_in_278012-Jun-22 12:36
professionalPeter_in_278012-Jun-22 12:36 
GeneralRe: Pattern Check Match Pin
Member 1567083112-Jun-22 13:46
Member 1567083112-Jun-22 13:46 
GeneralRe: Pattern Check Match Pin
Peter_in_278012-Jun-22 15:42
professionalPeter_in_278012-Jun-22 15:42 
AnswerRe: Pattern Check Match Pin
Member 1311558125-Sep-23 16:07
Member 1311558125-Sep-23 16:07 
QuestionAdresse erfassen mittels RegEx Pin
Member 156568991-Jun-22 3:26
Member 156568991-Jun-22 3:26 
AnswerRe: Adresse erfassen mittels RegEx Pin
OriginalGriff1-Jun-22 1:53
mveOriginalGriff1-Jun-22 1:53 
GeneralRe: Adresse erfassen mittels RegEx Pin
Member 156568991-Jun-22 11:39
Member 156568991-Jun-22 11:39 
GeneralRe: Adresse erfassen mittels RegEx Pin
OriginalGriff1-Jun-22 18:59
mveOriginalGriff1-Jun-22 18:59 
AnswerRe: Adresse erfassen mittels RegEx Pin
Richard MacCutchan1-Jun-22 22:01
mveRichard MacCutchan1-Jun-22 22:01 
GeneralRe: Adresse erfassen mittels RegEx Pin
Member 156568992-Jun-22 10:20
Member 156568992-Jun-22 10:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.