All Questions
36 questions
1
vote
1
answer
343
views
PowerShell: How to create Regex for a repeating pattern [duplicate]
I have below query I need to extract all the column name changes but if I use
$query = ",SELECT A.Title AS Identifier ,A.HOTELNAME AS PROPERTYNAME,A.REGION AS REGION,A.T0STATUS AS STATUS,"
$...
-1
votes
1
answer
112
views
How to speed up a Regex with Atomic groups?
The regular expression (.NET/C# flavor, or PS flavor) listed below matches elements and inner text in a simple XML file line by line (multiline matches are not necessary).
^[^<]*<(?'Element'[^&...
0
votes
3
answers
213
views
Problems with regex in PowerShell
First, I am completly new to regex and trying really hard to understand but getting very frustrated with it. Please bare with me here.
I am having problem understanding regex in PowerShell. I have ...
0
votes
0
answers
142
views
Regex to match comments in an INF file
While designing a Regex to match comments in an INF file ( its formal syntax definition is here ), I came across an insurmountable (to me) problem where a mismatch is occurring when an opening left ...
1
vote
2
answers
445
views
E-mail Regex causing catastrophic backtracking error
I am at the verge of loosing my mind over trying to fix an Email Regex i built:
It is almost perfect for what i need. It works in 99.9% of all cases.
But there is one case which causes a catastrophic ...
-2
votes
1
answer
456
views
Match comments unless the initiating character is surrounded by unescaped quotes
With a regex: How can I match comments which begin with a semicolon unless the semicolon is surrounded on both sides by unescaped quotes, as shown below (the green blocks denote the matched comments )?...
0
votes
2
answers
71
views
PowerShell/C# regex multiline replace returns wrong line ending
I have a textfile with CRFL line endings, I read the whole file with
$c = Get-Content -Raw file.txt
the file contains e.g.
exec Add a, b, c
exec Rem e, f, g
I try to replace it with my regex
$...
2
votes
2
answers
393
views
Using PowerShell Split & regex to return everything after a regex match
Going through PowerShell logs, I'm attempting to extract the commands while discarding the path the command was ran from. For example,
PS C:\Windows\system32> pwd
I'd only like to return pwd. I ...
0
votes
1
answer
45
views
why this regex does not work in powershell?
$pattern = 'trigger(.+?)(\r|\n|\r\n){2}'
Write-Host "PATTERN $pattern"
Write-Host ("- trigger: blah`n blah`n blah blah`n`n not blah" -replace $pattern, "trigger: none")
...
2
votes
2
answers
2k
views
Powershell Regular Expression to extract string between rounded parentheses from line in a log file
This is a line in a log file:
$line = 'to devices Headset Earphone (Some Device)'
I need the result done with an one liner regex only (if possible):
$result = 'Some Device'
I have it working in two ...
0
votes
1
answer
277
views
Converting C# to Powershell and Regex is not working or am I doing it wrong?
I'm trying to convert a simple C# class function into a Powershell module and for some reason it's not working. It feels like a Powershell syntax issue or quirk to me.
The C# one works fine but not ...
1
vote
2
answers
234
views
Convert 4 GB fixed column width text file with no delimiters and 100+ columns to a trimmed, tab delimited file
Monthly I receive several very large (~ 4 GB) fixed column width text file that needs to be imported into MS SQL Server. To import the file, the file must be converted into a text file with tab-...
-3
votes
1
answer
662
views
Generate Email Addresses with Special Characters [duplicate]
I am tasked with generating an email address for new users in our environment who may have special characters (such as an umlaut and accents) in their full names. While some email systems can handle ...
-1
votes
1
answer
56
views
unable to do multiple matches with regex pattern. pattern treats as a single match [duplicate]
I'm trying to match a pattern out of text which repeats with in the text. when i try match pattern it matches whatever in between. though I achieved the desired result but i might want any ...
1
vote
2
answers
118
views
Regex multiline log
I'd like to use a .NET / Powershell regex to search a log for Success status at a particular location, say ABC.
If I use the following pattern: "(?ms)A status: Success.*?Location: " with global (aka ...