Wildcard search for LINQ to SQL - search

I want to do a wildcard search using LINQ to SQL.
using Contains, StartsWith, EndsWith only.
(not "SqlMethods.Like" method)
the wild cards operate with two type of jokers:
? - any character (one and only one)
* - any characters (zero or more)
Is there a way to do this?
Regards

No it isn't possible. If you have both ? and * in your matching expression, there is no way to convert the ?.
Also, to convert ? by itself would require using Length.

Related

Want to find all results containing specific pattern in Azure Search explorer

I want to find all records containing the pattern "170629-2" in Azure Search explorer, did try with
query string : customOfferId eq "170629-2*"
which only give one result back, which is the exactly match of "170629-2", but i do not get the records which have the patterns of "170629-20", "170629-21" or "170629-201".
Two things.
1-You can't use standard analyzer as it will break your "words" in two parts:
e.g. 170629-20 will be breaked as 170629 and another entry as 20.
2-You can use regex and specify the pattern you want:
170629-2+.*
https://learn.microsoft.com/en-us/azure/search/query-lucene-syntax#bkmk_regex
PS: use &queryType=full to allow regex

How to count occurrences of a character in a string in Presto?

I am trying to find the number of frequency of a character in a string in Presto.
like 129.11.20.0 and I wan to find number of dot . in this string.
just wondering if any function available
I was looking for the same in AWS athena, which is a managed presto service. It doesn't support regexp_count, so I used the following expression instead:
SELECT CARDINALITY(REGEXP_EXTRACT_ALL('1.1.1.1', '\.'))
You can use regexp_count function.

Regex or IndexOf?

I have a long string "AB100123485;AB10064279293-IP-1-KNPO;AB473898487-MM41". I have to extract integer value after "IP-" i.e 1 (only) what is the most efficient way ? I am using c#
Thanks
The 'most-efficient' way depends on how consistent your string is in terms of length and appearance. You can surely do this with a regular expression as a quick solution if you just want to get the digit directly following IP-.
You can utilize the RegularExpressions API, passing in your regular expression and input string.
https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.match?view=netframework-4.8#System_Text_RegularExpressions_Regex_Match_System_String_System_String_
This pattern should get you started IP-[0-9]; refine it more to your use case as needed.
For example:
Match matched = System.Text.RegularExpressions.Match(
"AB100123485;AB10064279293-IP-1-KNPO;AB473898487-MM41",
"IP-[0-9]"
);

How to use reserved words in Azure Search Filter?

I am using Azure Search Filter option like follows
$filter=cityList/any(t: search.in(t, '1')) and name eq 'hi tech bar & restaurant' &search=*&scoringProfile=search-score&searchMode=Any&queryType=FULL
For all word filters except reserved words are working fine.
; / ? : # = + &
Can anyone help me to find how to use reserved words in Azure Search Filters ??
Thanks in advance.
There are two levels of encoding to consider. First, the OData expression itself. I'm assuming you need to use the special characters in a string constant, in which case the only character you need to encode is single quote, which you can encode by doubling. For example: $filter=Name eq 'O''Neil'. The second level of encoding depends on whether you're using HTTP GET or POST for your search request. If you're using the Azure Search .NET SDK, it takes care of this detail for you. If you're using the REST API directly and you're using GET, you need to URL encode the filter expression. If you're using POST, you need to encode the filter expression as you would any other JSON string. For example, you need to encode \ as \ and " as \", etc. Hope this helps.

How to use replace characters in excel?

I'm having trouble trying to use replace characters in MS excel. Help says * and ? can both replace characters, but if I try using them in IF, I don't get correct results.
For example:
A1="something"
=IF(A1="*mething";"yes";"no")
I always get no... How to use * correctly?
wildcards don't work with comparison operators like =
To achieve what you want you can use COUNTIF which does accept wildcards, i.e.
=IF(COUNTIF(A1;"*mething")>0;"yes";"no")
or RIGHT function like
=IF(RIGHT(A1;7)="mething";"yes";"no")
Wildcards cannot be used in this context. Use something like:
=IF(ISERROR(FIND("mething",A1)),"No","Yes")

Resources