Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Making the -match operator case sensitve

10,046 views
Skip to first unread message

john.william...@gmail.com

unread,
Dec 21, 2007, 3:45:29 AM12/21/07
to
Hi all.

When I use the "match" operator to compare to strings in the following
manner, the comparison is case insensitive:

"hello" -matches "HELLO"

The above evaluates to true. How can I make this comparison case
SENSITIVE?

Thanks in advance,
John

Jeff

unread,
Dec 21, 2007, 4:06:54 AM12/21/07
to

John,

I assume you meant to write '-match' rather than '-matches'. All of
the comparison operators have case sensitive and case insensitive
variants:

PSH$ "hello" -match "HELLO"
True
PSH$ "hello" -cmatch "HELLO"
False
PSH$ "hello" -imatch "HELLO"
True

The match is case insensitive by default, so '-match' is the same as '-
imatch'; '-imatch' is there so code that depends on case insensitivity
can be as clear as possible.

See 'help about_operator' for more information.

Jeff

Shay Levi

unread,
Dec 21, 2007, 3:59:00 AM12/21/07
to

To force case-sensitive match ("c.." stands for case-sensitive):

PS > "hello" -cmatch "HELLO"
False


There is also -imatch for case-insensitive, which is the default behaviour.

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic

0 new messages