All Questions
57 questions
1
vote
2
answers
161
views
Remove all label tags inside a string
I want to remove all label tags from a string.
This is the input string.
<p>
<title>Contact Us</title>
</p>
<table dropzone="copy">
<tbody>
&...
1
vote
1
answer
115
views
Get data between two tags
I need to extract text between two tags <mail> and </mail>
This is the text
<?xml version='1.0' encoding='utf-16'?>
<li xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='...
-1
votes
1
answer
62
views
unable to parse regex pattern form file to the variable in powershell
I am looking for whether the folder name is as per the below regex pattern in powershell.
Check first 4 letters are HOST.
Check next 3 or 4 letters as per the shortnames in the c:\shortnameslist.csv.
...
-1
votes
1
answer
34
views
How to include one line above of the keyword line during SPLITING a big txt file using Regex and PowerShell
We have got a big txt file ("C:\temp\longmessages.txt") like below:
Americas
This is Start
some text 1
some text 2
some text 3
etc. etc
End
Europe
This is Start
some text 4
some text 5
some ...
0
votes
1
answer
517
views
Rename all txt files in a folder based on file content
Can someone please help to use PowerShell to rename individual txt files in a folder, each file needs to be renamed based on a keyword inside each individual txt file.
e.g.
c:\temp\1.txt may have a ...
0
votes
4
answers
86
views
Get text between two characters
I have a plain text file like below:
"[email protected]"
"[email protected]"
"[email protected]"
and so on...
Now using Powershell I am trying to read line by line this plain text ...
0
votes
3
answers
35
views
Loop through a text file and Extract a set of 100 IP's from a text file and output to separate text files
I have a text file that contains around 900 IP's. I need to create batch of 100 IP's from that file and output them into new files. That would create around 9 text files.
Our API only allows to POST ...
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 ...
-2
votes
2
answers
1k
views
replace numbers - powershell
Trying to create a script which organizes each filename into: Year, Month & Day variables.
To do this in PowerShell with my current version I need to use -replace however it will only remove ...
0
votes
0
answers
467
views
How to extract a date (yyyy-dd-mm hh:mm:ss) from a string using powershell [duplicate]
I am a new bee to powershell, stuck with extracting the date from the below string
"C:\Program Files\PostgreSQL\data\logs\pg10\postgresql-Sun.log:12:2018-04-08 23:34:08 UTC [4052]: [1-1] user=testdb,...
1
vote
2
answers
666
views
powershell regex issue with powershell 2 vs. powershell 5 end of line anchor
Given the following code:
$inputString = "`r`n#cmakedefine BREAK_THE_CODE`r`n"
$match = '(?m)^(.*?)#cmakedefine(.*?)$'
$replace = 'hello $1#undef$2 goodbye '
$retVal = $inputString -replace $match,$...
1
vote
1
answer
119
views
Change file names with powershell DMY -> YMD
I have to change alot of files on a Windows computer and I will be using Powershell to do it.
The file names are like name_name_DDMMYYYY_XXXXXX.bmp
John_Doe_03062009_123456.bmp
...
0
votes
0
answers
125
views
Matching until you reach a string using Powershell 2.0
I'm trying to write a Regex that searches the source code of a series of webpages in a CSV file. I'm using the following to do the match:
$linkContent = $web.DownloadString($linkToBeConverted)
$...
1
vote
1
answer
76
views
Comparing installed and current versions
I want to get installed versions and current versions from a log file and I have got the output by using the following commands:
$versions = Select-String -Path $path -Pattern "Comparing product ...
0
votes
3
answers
6k
views
Filter the strings which startswith (one or two) slashes in PowerShell
I'm trying to find out the strings which starts with one slash(/) and two slashes(//). For example, following is the array which have few strings:
Following is the code I'm trying:
$array = @("/...