by dunagh at 2012-12-27 15:22:39
Can someone tell me why…by Klaas at 2012-12-28 00:22:39
“PC” -match “.”
…evaluates to True?
because -match does regular expression matching, and ‘.’ is the wildcard for any character. With other operators that would be ‘?’.by nohandle at 2012-12-28 05:04:10
[quote=“Klaas”]because -match does regular expression matching, and ‘.’ is the wildcard for any character.[/quote]by Klaas at 2012-12-28 07:14:22
For almost any character. By default it does not match new line characters.
[quote=“Klaas”]With other operators that would be ‘?’.[/quote]
Frankly I am not sure how you meant this. Can you calrify please?
The purpose of the ‘?’ sign is to make the previous group optional hence, “pc?” would match both ‘p’ and ‘pc’.
To match the ‘.’ as is. You have to escape the ‘.’ (or any metacharacter) by backslash like so:
‘a.b’ -match ‘a.b’
Personally I use http://www.regular-expressions.info/ to refer any regex question.
I mean that “PC” -like “?C” would return TRUE, because it uses wildcard expressions, as most operators do (-equals, -contains, -gt, -lt,…),by nohandle at 2012-12-28 07:53:47
but -match and -replace use regular expressions.
Thanks Klass, now it is clear.by dunagh at 2013-01-08 08:25:53
[quote=“Klaas”] -match and -replace [/quote]
and also -split.
Thanks for the answer. I thought I had tried to escape the period without success but I must have done something wrong with my original attempt. The evaluations are now working as expected.