extract a date from a STRING ROBOT FRAMEWORK - selenium

${my-string} "Fête : Anniversaire
Emplacement : Paris
Date : 08/12/2021
Prix : texte"
I need to extract the date from this text but i can't end up with a solution using robot framework , i tried :
${REGULAR EXPRESSION} \d{2}\/\d{2}\/\d{4}
Get Regexp Matches ${my-string} ${REGULAR EXPRESSION}
But it gave me null as a result , any solution for that please ?

I think because in Python/Robot Framework the backslash is treated as am escape character, you need an additional backslash on each occassion you use it in your reg ex
e.g. \\d{2}\\/\\d{2}\\/\\d{4}
So something like this should work:
*** Settings ***
Library String
*** Test Cases ***
Check Date Regex
${date} Set Variable Fête : Anniversaire Emplacement : Paris Date : 08/12/2021 Prix : texte
${regex} Set Variable \\d{2}\\/\\d{2}\\/\\d{4}
${matches} Get Regexp Matches ${date} ${regex}
${match} Set Variable ${NONE}
IF ${matches}
${match} Set Variable ${matches}[0]
END
log to console ${match}
With output:
08/12/2021

Related

Hive query to get the value for a given key in String

I am using regexp_extract for getting sub-string from a string
My string is ":abd: 576892034 :erg: 94856023MXCI :oute: A RF WERS YUT :oowpo: 649217349GBT GB"
How will get this using regexp_extract function.
I need the value as 576892034 if i pass the key as abd
Any other function also fine.
select
regexp_extract(
':adb: 576892034 :erg: 94856023MXCI :oute: A RF WERS YUT :oowpo: 649217349GBT GB',
':oute: ((?:.(?!:))+)',
1
)
manual : cloudera docs
example of regex : regex101

Odata filter DateTimeOffset less that date

I am trying to retrieve all records before specific date as follow:
?$filter=CreatedDate lt '2020-06-04T14:27:12.38'
but i keep receiving this error
"message": "The query specified in the URI is not valid. A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThan'.",
I tried to cast date
?$filter=CreatedDate lt cast('2020-06-04T14:27:12.38', Edm.DateTimeOffset))
but still the same .
also tried
?$filter=CreatedDate lt datetime'2020-06-04T14:27:12.38'
and received
The query specified in the URI is not valid. Unrecognized 'Edm.String' literal 'datetime'1995-09-01T00:00:00'' at '21' in 'CreatedDate gt datetime'1995-09-01T00:00:00''.
is there anyway to achieve that ?
You have to query date without quotation marks. An example from my application:
http://localhost/EDS4OData/EmployeeHoursVacationRequests?$filter=(Username eq 'jsmith' and DeleteInd eq false and DayOffType eq 2 and StartDate ge 2020-10-01T00:00:00.000Z and StartDate le 2020-12-31T23:59:59.999Z)&$count=true
In my C# model for the controller:
public DateTime StartDate { get; set; }
A quick googling lead me to this answer,
so try
?$filter=CreatedDate lt datetime'2020-06-04T14:27:12.38'
I managed to get it working like this:
?$filter=CreatedDate lt 2021-03-19T12:50:54.219Z
Check this answer: https://stackoverflow.com/a/27775965/3264998
if you are using .NET sdk to generate Storage Table query try using the TableQuery.GenerateFilterConditionForDate version
var timestampToFilter1 = TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThanOrEqual,
DateTimeOffset.Parse("2022-06-15T04:32:07.000Z") );
var timestampToFilter2 = TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.LessThanOrEqual,
DateTimeOffset.Parse("2022-06-15T12:32:07.000Z"));
var timestampToFilter = TableQuery.CombineFilters(timestampToFilter1, TableOperators.And, timestampToFilter2);

PIG filter by string

I'm trying to filter by a string but it fails. How do I filter by String? I tried looking here http://pig.apache.org/docs/r0.10.0/basic.html#comparison but matches only works for regular expressions.
f = FILTER finished_set by item is not matches '.*0000000000000.*';
ERROR org.apache.pig.PigServer - exception during parsing: Error
during parsing. mismatched
input 'matches' expecting NULL
f = FILTER finished_set BY NOT(item MATCHES '.*0000000000000.*');

Send SQL Email (href with colum)

I want to link the word Click with URL in the email. This URL change for every row of SELECT.
I write this:
td = CAST('Click' AS XML), ''
But SQL server return:
Análisis de XML: línea 1, carácter 73; se esperaba punto y coma
Which translates to
XML parsing : line 1 , character 73; expected semicolon
The & symbol should be encoded as &. The parser sees &orig and expects a semicolon after it (or at least at some point in the string).

How to parse string to get only desired text?

storeText ( locator, variableName )
${variableName}
If variableName contains value as 'Displaying 1 to 30 of 145300'.
I need to parse this string and store a value 145300 in another variable.
How is it possible ?
Command: storeEval
Target : '${variableName}'.split(' ').last()
Value : result