I have a term test* and I want to treat it as string and not a wildcard of test.
How will I be able to do that in Lucene.Net. Any help???
Yes you can use a backslash to escape special characters. Both in the QueryParser and custom built searches. List of characters that require escaping can be found here.
If you're using the newer versions of Lucene.Net, you can use QueryParser.Escape("test*") to escape your search term. QueryParser.Escape() takes a string and returns the string after properly escaping all characters that are special for Lucene.
Related
i am trying to find rows in a postgresql table where a specific column contains special characters excluding the following
#^$.!\-#+'~_
any help appreciated
Hi I think I figured it out. I found a solution that worked for me using Posix Regular Expressions.
SELECT *
FROM TABLE_NAME
WHERE fieldName ~ '[^A-Za-z0-9#^\\$.!\-#+~_]'
The regular expression matches any character that is not between A-Z, a-z, 0-9 and is also not any of your whitelisted characters ^$.!-#+~_. Notice that in the regex I had to escape the backslash and the hyphen, because they have a special meaning in regex. Maybe start by evaluating my proposed regex online with a few examples, e.g. here: https://regex101.com
Does PureScript support verbatim string literals? Something like #"regex \s no escapes" in C#.
Alternatively is there support for regex literals as in JavaScript?
You can use triple-quote strings.
There are no regex literals AFAIK, but triple-quote strings might help there too. Example from docs:
regex """.+#.+\..+""" noFlags
I have an string with some special characters.
The thing is, I want to search those special characters from the end of the string.
Is there any method available to search the index of character in backward direction?
Yes, use rangeOfCharacterFromSet:options:range: and use NSBackwardsSearch for the options argument.
For example, we want the search term "Test" to match the word "#Test" and "(Test)"in the results.
it does this by default. Unless you have added these chars to the charset_table in the config
Did you try with escape character backslash just before special characters.
Also check there is EscapeString function available in sphinx API.
I'm interested in using rangeOfString with some wildcard characters as part of a search string.
For example, if I have several strings like "244px" and "356px" and I want to convert all such strings to "320px". Is there a way I can use wildcards to get the desired result?
If you could use regex, you can do substitution for this pattern "[1-9][0-9]+px" to "320px"
RegexKitLite is what you want, it has a small NSString extenstion class that lets you use the built-in regex libraries easily.
Use NSNumberFormatter configured to the right pattern.