I have an issue, could you help me to understand how to extract first 5 characters from the filename in LogicApps. I'm able to create a variable and append it, so I have the list with file names, but then struggling to extract specific characters...
You can also use the take expression:
take(variables('my_string'),5)
This also work for arrays if you want to return the 5 first array items.
Use the substring expression ...
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#substring
substring('<text>', <startIndex>, <length>)
The expression within the First 5 Characters variable for the below result looks like this ...
substring(variables('String Variable'), 0, 5)
Result
Related
I need some help with the next. I have a field text in SQL, this record a list of times sepparates with '|'. For example
'14613|15474|3832|148|5236|5348|1055|524' Each value is a time in milliseconds. This field could any length, for example is perfect correct '3215|2654' or '4565' (only 1 value). I need get this field and replace all number with -1000 value.
So '14613|15474|3832|148|5236|5348|1055|524' will be '-1000|-1000|-1000|-1000|-1000|-1000|-1000|-1000'
Or '3215|2654' => '-1000|-1000' Or '4565' => '-1000'.
I try use regexp_replace(times_field,'[[:digit:]]','-1000','g') but it replace each digit, not the complete number, so in this example:
'3215|2654' than must be '-1000|-1000', i get:
'-1000-1000-1000-1000|-1000-1000-1000-1000', I try with other combinations and more options of regexp but i'm done.
Please need your help, thanks!!!.
We can try using REGEXP_REPLACE here:
UPDATE yourTable
SET times_field = REGEXP_REPLACE(times_field, '\y[0-9]+\y', '-1000', 'g');
If instead you don't really want to alter your data but rather just view your data this way, then use a select:
SELECT
times_field,
REGEXP_REPLACE(times_field, '\y[0-9]+\y', '-1000', 'g') AS times_field_replace
FROM yourTable;
Note that in either case we pass g as the fourtb parameter to REGEXP_REPLACE to do a global replacement of all pipe separated numbers.
[[:digit:]] - matches a digit [0-9]
+ Quantifier - matches between one and unlimited times, as many times as possible
your regexp must look like
regexp_replace(times_field,'[[:digit:]]+','-1000','g')
how do I write a SQL where statement that checks if a string contains some substring and a number. For example:
string: macsea01
where string like 'macsea' plus a number
Regex is the most obvious solution to this question. Without more detail about the specific format of the string, I can suggest the following, which will match a sequence of a letter in the alphabet followed immediately by a digit:
where column_name like '%[a-zA-Z][0-9]%'
If you're literally looking for macsea at the beginning of the string followed by a digit, it would be:
where column_name like 'macsea[0-9]%'
Regex seem to bee a little slippery here, depending on your needs you can for instance divide the string into several parts, first the text part, and take the rest of the string, try to convert it into a number.
Somthing like this (but I think this perticular code is broken
where substring(column_name, 1, 6) = 'macsea' and cast(substring(column_name, 7, 1000) as int) > 0
I have a table client_requests with the column number_request.
In the column number_request I have the following records:
20130000000008,
20130000000010,
20130000000503
I want to extract only the end of string without 0,
example:
for 20130000000008 I want to get 8
for 20130000000010 I want to get 10
for 20130000000503 I want to get 503
I think I need to use regexp_substr but do not know how.
One possible solution:
select replace('201500000010',regexp_substr('201500000010','.{4}0*'),'') from dual;
Essentially, I'm using the regexp_subst function to extract the unwanted digits, then using the replace function to replace the unwanted digits with '', which is nothing.
Given the following
Products_Joined.ProductName AS [stripHTML-TITLE],
How would I remove the first 5 characters when the field contain any of the following. Basically I want to strip out the characters between < and > and including <> as well. The returned field's length can vary.
<!01>AMSSSS
<!02>SSS
<!03>CMSS
<!04>DMSS
<!05>EMSDDDDD etc...
This gives me just the first characters after the > but I don't know how to get all characters after >
SUBSTRING(Products_Joined.ProductName, 6,1) AS [stripHTML-TITLE],
Was going to use Replace function for all the possible prefixes but that can get rather messy.
SUBSTRING(Products_Joined.ProductName, 6,LEN(Products_Joined.ProductName))
You can use STUFF.
select stuff('<!01>AMSSSS', 1, 5, '')
http://msdn.microsoft.com/en-us/library/ms188043.aspx
jkdfhdjfhjh&name=ijkjkjkjkjkjk&id=kdjkjkjkjkjkjjjd&class=kdfjjfjdhfjhf
The above string has some characters starting with & and ending with =
for example we have &name= and I just need this from the above string.
similarly I need &id=, &class=
I need the output under a single column.
Final Extract
----------------------
&id=, &class=, &name=
can anyone help me out in writing a query for this.
You could try this :
select regexp_replace('jkdfhdjfhjh&name=ijkjkjkjkjkjk&id=kdjkjkjkjkjkjjjd&class=kdfjjfjdhfjhf', '\\w*?(&.*?=)\\w+((?=&)|$)', '\\1, ', 'g');
result:
regexp_replace
-------------------------
&name=, &id=, &class=,
Then it's up to you to remove the last ,.
The regexp_replace function is available in version 8.1 and after.
If you want the values along with each variable, I would implement this by splitting on "&" into an array and then taking a slice of the desired elements:
SELECT (string_to_array('jkdfhdjfhjh&name=ijkjkjkjkjkjk&id=kdjkjkjkjkjkjjjd&class=kdfjjfjdhfjhf','&'))[2:4];
Output in PostgreSQL 8.4 (array type):
{name=ijkjkjkjkjkjk,id=kdjkjkjkjkjkjjjd,class=kdfjjfjdhfjhf}
The example string is very wide so here's the general form to show the array slicing more clearly:
SELECT ((string_to_array(input_field,'&'))[2:4];
NOTE: You must have the extra parentheses around the string_to_array() call in order for the array slicing to work--you'll get an error otherwise.