Skip to main content

All Questions

0 votes
0 answers
85 views

Negative lookahead not working as intended

I would like to create a regex, that matches along the following criteria and I am using the Select-String function of PowerShell. I have this query,and I want to get all parameter variations(so the ...
StingerWolf's user avatar
0 votes
1 answer
145 views

regex lookbehind is `>` a shortcut for `<=`?

Through some convoluted testing, I ended up potentially discovering a shortcut. A lookbehind in PowerShell is supposed to use the <= syntax, which is referenced in various other places when ...
Blaisem's user avatar
  • 657
1 vote
1 answer
370 views

How to match, but not capture, part of a regex with Powershell

I have a line in a text doc that im trying to pull data from. Example Line im searching for in Text file: Valid from: Sun May 17 19:00:00 CDT 1998 I want to find the key words "Valid from:"...
user6534872's user avatar
1 vote
1 answer
71 views

Regular Expression misses matches in string

I'm trying to write a regular expression that captures desired strings between strings ("f38 ","f38 ","f1 ", "..") and ("\par","\hich",&...
Michael Callahan's user avatar
0 votes
2 answers
3k views

Select-string regex

I'm searching a ton of logs using a foreach loop for a string ($text) and currently outputting the entire line to an output file ($logfile) Get-ChildItem "\\$server\$Path" -Filter "*....
dbutts's user avatar
  • 43
0 votes
3 answers
98 views

Easiest way to REGEX Capture eveything except what you specify?

I for the life of me cannot figure out how to negate everything but what I want to capture with REGEX. I get close with [^(\d{4}-\d{3}-\d{3}] But doing a replace in powershell with an input of: 1234-...
Ryan Jamison's user avatar
0 votes
1 answer
742 views

Regex using negative lookahead missing first character of group2

I need to get the LDAP group names from this example string: "user.ldap.groups.name" = "M-Role13" AND ("user.ldap.groups.name"= "M Role1" OR "user.ldap.groups.name" = "M.Group-Role16" OR "user.ldap....
Victor Cruz's user avatar
2 votes
2 answers
5k views

RegEx for not matching a sequence in PowerShell

I want to validate a string and the regex should not match when a dot "." has a "-" or "_" directly before or after it. I assume a negative lookahead would be the best approach but I can't seem to ...
Glenn's user avatar
  • 655
1 vote
3 answers
953 views

RegEx for matching specific words and ignoring new lines

Full Text = " ...... A= B= 12345 ....." I want to get empty word "" between A= and line break. and want to get "12345" between B= and line break. How can I get words using regular expression? (?&...
Mason Lee's user avatar
4 votes
3 answers
3k views

Select-String: match a string only if it isn't preceded by a specific character

I have a list of files that contain either of the two strings: "stuff" or ";stuff" I'm trying to write a PowerShell Script that will return only the files that contain "stuff". The script below ...
Jay Schwegler's user avatar
2 votes
1 answer
51 views

Regex lookahead part of group accepted

I'm using regex in powershell 5.1. I need it to detect groups of numbers, but ignore groups followed or preceeded by /, so from this it should detect only 9876. [regex]::matches('9876 1234/56',‘(?&...
Jlisk's user avatar
  • 333
3 votes
4 answers
1k views

Regular Expressions in powershell split

I need to strip out a UNC fqdn name down to just the name or IP depending on the input. My examples would be \\tom.overflow.corp.com \\123.43.234.23.overflow.corp.com I want to end up with just ...
jim wood's user avatar
2 votes
1 answer
422 views

Regex - Match a single instance/occurrence of a character per line

I really am not getting how I can match just a single instance of both a whitespace or a dash. I am able to get some results but still unable to get the desired one. I have actually tried different ...
CodeNagi's user avatar
  • 419
0 votes
4 answers
850 views

regex lookbehind

I have a problem with regex lookbehind! here is my sample text: href="dermatitis&gt;" "blah blah blah &gt;" href="lichen-planus&gt;" I want to match all &gt;" if and only if there ...
john sadeghi's user avatar
1 vote
1 answer
82 views

PowerShell Issues with getting string from file

Problem I am working on an automated version control script in powershell and I hit a snag where I am trying pull a line of text from an AssemblyInfo.cs file. However, I can't seem to get it to work ...
Brandon's user avatar
  • 771

15 30 50 per page