Main Area and Open Discussion > General Software Discussion
Extract REGEX matches from multiple text files
kalos:
Also, I still have not figured out how to make Powershell match . any character including newline... Any hint?-kalos (August 20, 2018, 09:36 AM)
--- End quote ---
Learn to use Powershell's built-in help system:
--- Code: PowerShell ---Get-Help about_comparison_operators
Learn to use Google:
http://lmgtfy.com/?q=powershell+regex+match+any+character+including+newline
http://lmgtfy.com/?q=powershell+regex+match+multiline
http://bfy.tw/JV48
-4wd (August 20, 2018, 07:15 PM)
--- End quote ---
I tried that but it is not clear if (?s) goes to either:
at the beginning of the regex and after the '
at the beginning of the regex and before the '
just before .
Any idea?
wraith808:
but I cannot see in the list of operators the OR :tellme:-kalos (August 21, 2018, 04:02 AM)
--- End quote ---
--- Code: PowerShell ---Get-Help about_Logical_Operators-4wd (August 21, 2018, 07:49 AM)
--- End quote ---
I did that, but I get this:
--- ---PS H:\> Get-Help about_Logical_Operators
Get-Help : Get-Help could not find about_Logical_Operators in a help file in this session. To download updated help
topics type: "Update-Help". To get help online, search for the help topic in the TechNet library at
http://go.microsoft.com/fwlink/?LinkID=107116.
At line:1 char:1
+ Get-Help about_Logical_Operators
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
+ FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand-kalos (August 21, 2018, 08:31 AM)
--- End quote ---
--- Code: PowerShell ---Get-Help about_*
if you don't see it there,
--- Code: PowerShell ---get-help update-help
kalos:
Thanks, but it needs me to run it as admin, which I cannot.
Any idea why the below does not work?
(gc *.xml) -match '(?s)<\?xml\ version="1\.0"\ encoding="UTF-8"\?>.+?</dbts:PmryObj>'
Ath:
Any idea why the below does not work?
-kalos (August 21, 2018, 09:42 AM)
--- End quote ---
As usual you are asking half questions without *any* documentation. And you still haven't answered all previous questions, as requested, (and even have asked new questions in the half-baked 'answer') so in my book, you're not yet ready to ask new questions.
wraith808:
Thanks, but it needs me to run it as admin, which I cannot.
-kalos (August 21, 2018, 09:42 AM)
--- End quote ---
TOPIC
about_Logical_Operators
SHORT DESCRIPTION
Describes the operators that connect statements in Windows PowerShell.
LONG DESCRIPTION
The Windows PowerShell logical operators connect expressions and
statements, allowing you to use a single expression to test for multiple
conditions.
For example, the following statement uses the and operator and
the or operator to connect three conditional statements. The statement is
true only when the value of $a is greater than the value of $b, and
either $a or $b is less than 20.
($a -gt $b) -and (($a -lt 20) -or ($b -lt 20))
Windows PowerShell supports the following logical operators.
Operator Description Example
-------- ------------------------------ ------------------------
-and Logical and. TRUE only when (1 -eq 1) -and (1 -eq 2)
both statements are TRUE. False
-or Logical or. TRUE when either (1 -eq 1) -or (1 -eq 2)
or both statements are TRUE. True
-xor Logical exclusive or. TRUE (1 -eq 1) -xor (2 -eq 2)
only when one of the statements False
is TRUE and the other is FALSE.
-not Logical not. Negates the -not (1 -eq 1)
statement that follows it. False
! Logical not. Negates the !(1 -eq 1)
statement that follows it. False
(Same as -not)
Note: The previous examples also use the equal to comparison
operator (-eq). For more information, see about_Comparison_Operators.
The examples also use the Boolean values of integers. The integer 0
has a value of FALSE. All other integers have a value of TRUE.
The syntax of the logical operators is as follows:
<statement> {-AND | -OR | -XOR} <statement>
{! | -NOT} <statement>
Statements that use the logical operators return Boolean (TRUE or FALSE)
values.
The Windows PowerShell logical operators evaluate only the statements
required to determine the truth value of the statement. If the left operand
in a statement that contains the and operator is FALSE, the right operand
is not evaluated. If the left operand in a statement that contains
the or statement is TRUE, the right operand is not evaluated. As a result,
you can use these statements in the same way that you would use
the If statement.
SEE ALSO
about_Operators
Compare-Object
about_Comparison_operators
about_If
--- End quote ---
If you can't run an elevated command prompt... good luck in this endeavor. You're going to need it.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version