All Questions
Tagged with powershell regex
2,299
questions
2
votes
2
answers
43
views
Difficulty understanding "replace" combined with RE and scriptblock in Powershell
The script is designed to search for users located in $ListOfDismissedEmpl and doing something else...
$ListOfDismissedEmpl = "22261,24996,25340".Split(",")
$filter = $...
3
votes
3
answers
82
views
Renaming string via key/value matrix
I am attempting to rename strings that have been pulled from a user-defined field. So, I have set up a matrix that creates a relationship between what comes from the UDF and what I want that string to ...
1
vote
1
answer
52
views
Regex Guide: Getting a specific value from a text file using powershell/cmd
Im using powershell or cmd to open a text file and get a specific value or text inside.
Currently the output looks like this inside the text file:
Upload Hello.zip: 0 of 933 bytes complete
Upload ...
1
vote
1
answer
65
views
Regexp in findstr to find URLs in txt files in all subfolders
I struggle with a pretty simple CMD task.
I have a root folder (C:\folder) in which I have many subfolders and each of them contains different kind of files. I want to search all txt files in all ...
0
votes
3
answers
57
views
Regex that captures everything between matches but NEGATES the matches [duplicate]
Example string:
[fun-stuff-thats-fun-goes-here] dumbstuffidontwantishere\
I want the string between the brackets, but I want to negate the brackets.
Regex i've tried:
[^\[]*[\]]
This produces:
fun-...
2
votes
1
answer
57
views
Multiple matches with capture groups in PowerShell regex
I'm trying to understand why the following regular expression does not do what I expect in Powershell.
\["(Total|Group1|Group2)",(\d+),\d*,,,,,\d+,\d+\]
I would expect this to return nine ...
3
votes
3
answers
85
views
Extracing C structs into separate files with regex
I am cleaning up a C project which has a single header file that contains all used structs.
I want to extract all structs and put them into separate files using PowerShell Regex.
I have written the ...
1
vote
2
answers
70
views
Regex stop at space & skip rest of the info in a line
I am working with some data that the last portion of sometimes has additional information than others. When this additional information exists, I need regex to skip it and move on to the next line.
So ...
1
vote
1
answer
53
views
Replace first occurrence of a series of one or multiple spaces in line
I'm trying to replace the first occurrence of one or multiple spaces of lines in a file.
Reading the file line by line is no problem, but i'm having issues with the regex replacing just the first ...
0
votes
2
answers
98
views
Regular Expression to extract Urls from file
I am currently working on a regular expression to extract urls from a file. here is what I have come up with so far:
(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?(/(\w|\.)*)*
however the ...
0
votes
1
answer
62
views
Regex to match list of words
I want to extract countries from a list of files names. The countries can appear multiple times, separated by a comma and space.
My regex (used in Powershell 7):
$regex = "^[^\(]* \(([\b(USA|...
1
vote
1
answer
43
views
Edit a css file using a regular expression in Powershell
Excerpt of my current theme.css file:
.actionBlock[selected] {
color: var(--gray11);
background-color: var(--gray11);
}
I want change color: var(--gray11); into color: #FFF; /* ...
2
votes
2
answers
54
views
How to Change case of part of Filename with Powershell and Regex?
Have a bunch of Video files, that all contain either 1080P / 720P in the end of Base Filename but before the Extension usually, but we can assume all the filenames have either one of two anywhere in ...
1
vote
1
answer
37
views
Powershell Remove part of Video filename containing Square/Round brackets and everything inside those brackets
I have several videos that has either round brackets and/or square brackets with some text inside those like (ANTYHING HERE) OR [ANTHING HERE]:
For example:
MOVIENAME 2024 LANG [SOMETEXTHERE] 1080P....
1
vote
2
answers
128
views
Extracting words from certain lines using regex in powershell
I'm trying to find words in a text file using powershell and print them into another file.
Those words do not really have any properties that would distinguish them among other words except for the ...