autoComplete.js Unterminated group error when typing an opening parenthesis - autocomplete

I am trying to implement autoComplete.js on this site: http://bydaylight.com/testing/patent-defenses/
Some of the terms in our data have parenthesis like this:
112(1/a)
When I start typing in that exact string, I get an error after typing the opening parenthesis
Uncaught (in promise) SyntaxError: Invalid regular expression: /112(/: Unterminated group
autocomplete.js error screenshot
The data itself is just a simple array. Looks like this:
["100", "101", "112", "119", "120", "135", "273", "287", "295", "365", "102(e) ", "112(1/a)", "112(2/b)", "112(4/d)", "112(6/f) ", "271(a)", "271(b)", "271(c) ", "271(e) ", "271(f) ", "271(g)", "abatement", "ACQUIESCENCE", "admitted prior art", "Alice"]
Is there any special formatting I need to consider? Just looking for some guidance.

You're getting that error because of autoComplete.js matching method in strict mode is regex which conflicts with the brackets because it's considered as an invalid character and should be escaped inside regex pattern.
So you've two options for now to solve your issue:
Use loose mode instead of strict
Escape invalid characters before processing through query

Related

what does caret do in postgresql?

I'm playing hackthebox machine's and current one has a postgresql db in place. The query breaks with ' and appeas as follows:
ERROR: unterminated quoted string at or near "'" LINE 1: Select * from
cars where name ilike '%test'%' ^
I understand that % is being used to search within the query string for the characters provided but, What is ^ used for?
Bold highlights my test query
All my searches yielded resulst regarding regexes and caret signaling the start of the string. Plus other result about using cli or something like that.
Can anybody tell me what is it doing at the end of the query?
Your are looking for the use of the caret specifically within error messages.
If I run this query:
psql -c " Select * from cars where name ilike '%test'%'"
This is what I get, preserving line breaks and spaces:
ERROR: unterminated quoted string at or near "'"
LINE 1: Select * from cars where name ilike '%test'%'
^
The caret points to where on the previous line the error occurred. In this case, that is where the opening quote mark that never got closed was located.
If you are using a tool which malformats your error messages, you should consider changing to one that does not or otherwise figuring out how to fix it.

ReasonML: Unclosed "("

if(1<Array.length(Node.Process.argv)) {
Js.log("Too many arguments!");
}
The above 3-line ReasonML program does not compile:
Error: Unclosed "(" (opened line 1, column 2)
Tongue-in-cheek question: what is wrong? This is my pet peeve about ReasonML, because I counted parentheses and they do match.
I believe you need to insert a space after the <. As for the details of why this happens, I'm asking on Discord. I assume it has something to do with JSX.

How to fix mismatch input x expecting y

I am new to antler and creating a parse tree. I am trying to create tokens that include a special character, but when I do so it gives me an input mismatch.
I have tried to add a special character to my LEXER rules by adding a '.' at the end, however when I do so it give me the error of input mismatch. The snippet of code that I am trying will work on its own but not as part of the entire code.
This is the code I have so far...
grammar Grammar4;
r : WORD', 'NUMBER', 'BOOL', 'SENT+;
BOOL : 'true' | 'false';
WORD : [a-zA-Z]+;
NUMBER : [0-9]+;
SENT : [a-zA-Z ]+;
WS : [ \t\r\n]+ -> skip ;
If I add a period at the end of SENT to allow for special characters ([a-zA-Z ]+.;) then I get an input mismatch. If I take that line out and use it independently of the rest than I can have a sentence like, "How are you today!" and have it tokenize fine.Any help is greatly appreciated.
Edited for clarity:
I am trying to parse a statement like, Alex, 31, false, I let the dog out! (note that I can get everything to parse as an individual token except the last special character and I would like "I let the dog out!" to be one token.

Variable substitution of multiline list of strings in PostgreSQL

I'm trying to substitute the list in the following code:
kategori NOT IN ('Fors',
'Vattenfall',
'Markerad vinterled',
'Fångstarm till led',
'Ruskmarkering',
'Tält- och eldningsförbud, tidsbegränsat',
'Skidspår')
I found this question for the multiline part. However
SELECT ('Fors',
'Vattenfall',
'Markerad vinterled',
'Fångstarm till led',
'Ruskmarkering',
'Tält- och eldningsförbud, tidsbegränsat',
'Skidspår') exclude_fell \gset
gives
ERROR: column "fors" does not exist
LINE 1: SELECT (Fors,
^
, so I tried using triple quotes, dollar quotation and escape sequenses. Nothing has worked to satisfaction. This is true even if I use a single line variable and \set, so I must have misunderstood something about variable substitution. What is the best way of doing this?

Sphinx PHP API EscapeString() function doesn't work for SphinxQL?

I found the following function in the Sphinx PHP API code:
function sphinxapi_EscapeString($string)
{
$from = ['\\', '(', ')', '|', '-', '!', '#', '~', '"', '&', '/', '^', '$', '=', '<'];
$to = ['\\\\', '\(', '\)', '\|', '\-', '\!', '\#', '\~', '\"', '\&', '\/', '\^', '\$', '\=', '\<'];
return str_replace($from, $to, $string);
}
However, it doesn't seem to work properly because when I use strings with certain characters in them in queries Sphinx throws exceptions.
An example is the quote character ". EscapeString() puts a backslash \ in front of it, but Sphinx throws an exception saying:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 index my_index: syntax error, unexpected $end near ''' in ..
If I add two more backslashes, making it \\\", then no error is thrown.
What's the deal here? Why isn't EscapeString() working?
You havent shared your exact code, but I wonder if you JUST calling this function, need to escape as per SQL rules too.
EscapeString ONLY escapes the query to escape the Extended Syntax charactors.
Thats all that is required in the API, as the Query/AddQuery function takes the query directly.
But in SphinxQL the query string is inside a SQL statement, so the string needs 'SQL String' escaping before being embedded in the statement (whether or not you ALSO escape like EscapeString does). PDO can do it automatically if you use prepared statements, otherwise use the PDO quote function.
(A Query like SELECT ... MATCH('one \" ') isnt escaped propelly, as the slash is 'swallowed' by the SQL parser, not making it through to the Full text Query parser)