开发者

Powershell -like expression from a SQL LIKE expression

开发者 https://www.devze.com 2023-01-10 10:15 出处:网络
I have a table in my database that includes some columns that a开发者_如何学JAVAre used for LIKE expressions in SQL. The process I\'m working with uses those expressions to exclude certain SQL objects

I have a table in my database that includes some columns that a开发者_如何学JAVAre used for LIKE expressions in SQL. The process I'm working with uses those expressions to exclude certain SQL objects from processing.

I'm now putting similar code in Powershell, but I'd like to keep the columns consistent. I'm going to need to do something along the lines of:

where {$someVariable -like $myColumnData}

Is there any way to change a SQL LIKE expression into a Powershell -like expression? I might be able to write my own, but this seems like it would be tricky and error-prone, so if someone has already done the work, that would be great.

As an example, I'd like to be able to do conversions like the following:

%some string%    -->    *some string*
[0-9]blah%       -->    <I don't know what would go here>blah%

As a side-question, does the Powershell -like allow any standard regex expression or is it limited to ? and * wildcards?

Thanks!


It's the same. Take a look here, at wildcard characters for powershell: http://msdn.microsoft.com/en-us/library/aa717088(VS.85).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号