Click here to Skip to main content
15,393,706 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
QuestionNon Zero Number Pin
cad-one26-Jul-22 8:11
Membercad-one26-Jul-22 8:11 
AnswerRe: Non Zero Number Pin
k505426-Jul-22 10:46
mvek505426-Jul-22 10:46 
GeneralRe: Non Zero Number Pin
cad-one26-Jul-22 11:09
Membercad-one26-Jul-22 11:09 
QuestionRegex before match Pin
moxol20-Jul-22 22:09
Membermoxol20-Jul-22 22:09 
AnswerRe: Regex before match Pin
Peter_in_278021-Jul-22 1:31
professionalPeter_in_278021-Jul-22 1:31 
GeneralRe: Regex before match Pin
moxol21-Jul-22 2:00
Membermoxol21-Jul-22 2:00 
GeneralRe: Regex before match Pin
jsc4221-Jul-22 2:56
professionaljsc4221-Jul-22 2:56 
GeneralRe: Regex before match Pin
moxol21-Jul-22 3:55
Membermoxol21-Jul-22 3:55 
QuestionPerl regex anchor merely matches at the position of the end of previous match period Pin
marbooth18-Jul-22 6:23
Membermarbooth18-Jul-22 6:23 
AnswerRe: Perl regex anchor merely matches at the position of the end of previous match period Pin
marbooth18-Jul-22 17:18
Membermarbooth18-Jul-22 17:18 
GeneralRe: Perl regex anchor merely matches at the position of the end of previous match period Pin
RedDk20-Jul-22 6:23
MemberRedDk20-Jul-22 6:23 
QuestionIsn't ?= needless? Pin
Member 1570882016-Jul-22 22:38
MemberMember 1570882016-Jul-22 22:38 
AnswerRe: Isn't ?= needless? Pin
Dave Kreskowiak17-Jul-22 6:28
mveDave Kreskowiak17-Jul-22 6:28 
GeneralRe: Isn't ?= needless? Pin
Member 1570882019-Jul-22 21:48
MemberMember 1570882019-Jul-22 21:48 
GeneralRe: Isn't ?= needless? Pin
Dave Kreskowiak20-Jul-22 3:41
mveDave Kreskowiak20-Jul-22 3:41 
Questionregex code assistance for entering 600 in a input field Pin
Member 1568365422-Jun-22 4:13
MemberMember 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
MemberMember 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
MemberMember 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
MemberMember 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
MemberMember 1567083112-Jun-22 6:22 

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.