I am trying to do a like for following charecters,
[C0-S12]ECT-PM18052
As metnioned in this post I tried following query,
WHERE Barcode LIKE '[[C0-S12]%'
and this returns everything. It completely ignores the left side which is constant. For example I am getting back following results back.
[C0-S12]ECT-PM18052
[C0-S8]ECT-PM18052
[C0-B14]ECT-PM18052
[C0-S17]ECT-PM18052
[C0-B3]ECT-PM18052
[C0-S7]ECT-PM18052
[C0-B12]ECT-PM18052
I have also tried following this post and escaped using '/ /'.
WHERE Barcode LIKE '\[C0-S12%\'
and this does not return anything atll.
This version works:
WHERE Barcode LIKE '$[C0-S12]%' ESCAPE '$'
I notice that the \ escape doesn't work on Rextester. It should work, but it doesn't.
Related
I'm working on extracting an email address from the additionalextensions column in Sentinel. I've found a regex that works perfectly in a calculator, extracting everything after a colon (:) up to a semicolon followed by the latter s (;s). However, it does not work in Kusto I suspect because its using a lookback?
Below is the regex that worked in the calculator:
(?<=:).*(?=;s)
This is data from one of the logs:
cat=EXFILTRATION;account=O365:email.address#test.org.uk;start=1659975196000;end=165997519600
When using the calculator, it returns the below:
email.address#test.org.uk
However, when trying to use this in Kusto, it returns the original data. Is anyone able to come up with a way I can achieve this in KQL?
extracting everything after a colon (:) up to a semicolon followed by the latter s (;s).
you don't have to use a regular expression.
for instance, using the parse operator:
print input = 'cat=EXFILTRATION;account=O365:email.address#test.org.uk;start=1659975196000;end=165997519600'
| parse input with * ":" email_address ";s" *
input
email_address
cat=EXFILTRATION;account=O365:email.address#test.org.uk;start=1659975196000;end=165997519600
email.address#test.org.uk
I have video embed code stored in a database table. We use multiple video sources, including YouTube, Viddler, and locally-stored flash files. I need to find all the records with flash files. The body field for a flash record looks like this:
[swf file="/sites/default/files/lecture-video/2010_02_beier_schanzer.swf" width="702" height="560"]
I was hoping to do something like this:
SELECT * FROM `node_revisions` inner join node on node_revisions.nid = node.nid where node.type = "video" and node_revisions.body REGEXP "^[swf"
but got the following error:
39 - Got error 'brackets ([ ]) not balanced' from regexp
How can I escape the bracket when it's the first character I'm looking for?
You have to use two backslashes.
regexp '^\\[swf'
I want to extract a set of characters between "u1=" and the first semi-colon using a regex. For instance, given the following string: id=1w54;name=nick;u1=blue;u2=male;u3=ohio;u5=
The desired regex output should be just blue.
I tested (?<=u1=)[^;]* on https://regex101.com and it works. However, when I run this in BigQuery, using regexp_extract(string, '(?<=u1=)[^;]*') , I get an error that reads "Cannot parse regular expression: invalid perl operator: (?<"
I'm confused why this isn't working in BQ. Any help would be appreciated.
You can use regexp_extract() like this:
regexp_extract(string, 'u1=([^;]+)')
This is probably a simple problem but unfortunately I wasn't able to get the results I wanted.
I have the following input line
A[C1234/3/4]b[123/0]C[123/0]d[123/0]E[123/0]d[http://google.com]AD[M/1/2]g[ab]
I want to retrieve the numbers using regex_extract in Hive
1/2
which is followed by "AD[M/ " in each case.
I am currently using
'\(AD([^)]+)\)' which gives output AD[M/1/2]g[ab]
Implementing any other like (//d*) is give a code 2 error. Please suggest the possible replacements
Try this regex
.*AD\[M\/(.*)\].*
by the way () should be the capturing bracket pair, not \(\)
I need to send a properly formatted date comparison WHERE clause to a program on the command line in bash.
Once it gets inside the called program, the WHERE clause should be valid for Oracle, and should look exactly like this:
highwater>TO_DATE('11-Sep-2009', 'DD-MON-YYYY')
The date value is in a variable. I've tried a variety of combinations of quotes and backslashes. Rather than confuse the issue and give examples of my mistakes, I'm hoping for a pristine accurate answer unsullied by dreck.
If I were to write it in Perl, the assignment would I think look like this:
$hiwaterval = '11-Sep-2009';
$where = "highwater>TO_DATE(\'$hiwaterval\', \'DD-MON-YYYY\')";
How do I achieve the same effect in bash?
hiwaterval='11-Sep-2009'
where="highwater > TO_DATE('$hiwaterval', 'DD-MON-YYYY')"
optionally add "export " before final variable setting if it is to be visible ourside the current shell.
Have you tried using using double ticks? Like highwater>TO_DATE(''11-Sep-2009'', ''DD-MON-YYYY''). Just a suggestion. I haven't tried it out.
You can assign the where clause like this:
export WHERECLAUSE=`echo "where highwater >TO_DATE('11-Sep-2009', 'DD-MON-YYYY')"`
(with backticks around the echo statement - they're not showing up in my editor here...)
which works with a shell script of the form:
sqlplus /nolog <<EOS
connect $USERNAME/$PASSWD#$DB
select * from test $WHERECLAUSE
;
exit
EOS