DBFit: How to assert against regular expression - database

I am trying to assert the output of a stored procedure against a regular expression. Consider the following example:
!|Execute Procedure|CONCAT_ERROR_MESSAGES|
|x_error_message |l_error_message_in |x_error_message? |
|hello!-||-! |!-||-!world |=~/world/ |
The FitNesse docs say it is possible using the slim engine. DBFit is using Fit and I can't find much related to this.
http://fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ValueComparisons
Any help would be greatly appreciated.
Thanks

Related

what is the use of total(currentMeausure within head set) in cognos

I have a question regarding COGNOS inbuilt function.
I have a report of another developer in which he is using the inbuilt function total(currentMeausure within head set) in COGNOS. My task is to enhance the report. And the fields which have to be enhanced are using this function and I have no idea what this function is doing here.
Thanks,
Regards
Hajrah Naeem
I have searched a lot on google but didn't find accurate description about it. Can anyone explain me this function in easy way with some example so that I can continue my work?
Total is the aggregation to be done on the measure.
CurrentMeasure is either the defaultMeasure on the Crosstab or the Measure projected on an edge
Within set(head(dimension/level/set,N)) means the first N members of the defined object.
So for total(currentMeasure within set(head([ProductLine],3)) would give you total of the first 3 members in the ProductLine level.

Snowflake and Regular Expressions - issue when implementing known good expression in SF

I'm looking for some assistance in debugging a REGEXP_REPLACE() statement.
I have been using an online regular expressions editor to build expressions, and then the SF regexp_* functions to implement them. I've attempted to remain consistent with the SF regex implementation, but I'm seeing an inconsistency in the returned results that I'm hoping someone can explain :)
My intent is to replace commas within the text (excluding commas with double-quoted text) with a new delimiter (#^#).
Sample text string:
"Foreign Corporate Name Registration","99999","Valuation Research",,"Active Name",02/09/2020,"02/09/2020","NEVADA","UNITED STATES",,,"123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES","123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES",,,,,,,,,,,,
RegEx command and Substitution (working in regex101.com):
([("].*?["])*?(,)
\1#^#
regex101.com Result:
"Foreign Corporate Name Registration"#^#"99999"#^#"Valuation Research"#^##^#"Active Name"#^#02/09/2020#^#"02/09/2020"#^#"NEVADA"#^#"UNITED STATES"#^##^##^#"123 SOME STREET"#^##^#"MILWAUKEE"#^#"WI"#^#"53202"#^#"UNITED STATES"#^#"123 SOME STREET"#^##^#"MILWAUKEE"#^#"WI"#^#"53202"#^#"UNITED STATES"#^##^##^##^##^##^##^##^##^##^##^##^#
When I try and implement this same logic in SF using REGEXP_REPLACE(), I am using the following statement:
SELECT TOP 500
A.C1
,REGEXP_REPLACE((A."C1"),'([("].*?["])*?(,)','\\1#^#') AS BASE
FROM
"<Warehouse>"."<database>"."<table>" AS A
This statement returns the result for BASE:
"Foreign Corporate Name Registration","99999","Valuation Research",,"Active Name",02/09/2020,"02/09/2020","NEVADA","UNITED STATES",,,"123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES","123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES"#^##^##^##^##^##^##^##^##^##^##^##^#
As you can see when comparing the results, the SF result set is only replacing commas at the tail-end of the text.
Can anyone tell me why the results between regex101.com and SF are returning different results with the same statement? Is my expression non-compliant with the SF implementation of RegEx - and if yes, can you tell me why?
Many many thanks for your time and effort reading this far!
Happy Wednesday,
Casey.
The use of .*? to achieve lazy matching for regexing is limited to PCRE, which Snowflake does not support. To see this, in regex101.com, change your 'flavor" to be anything other than PCRE (PHP); you will see that your ([("].*?["])*?(,) regex no longer achieves what you are expecting.
I believe that this will work for your purposes:
REGEXP_REPLACE(A.C1,'("[^"]*")*,','\\1#^#')

Regexp_extract using Google re2

I need to extract the following text string using google/re2:
Audiences » Affinity Categories » Food & Dining » Fast Food Cravers
In sum, any string after no.3 »
Would appreciate any help/ guidance, million thanks!
best,
yg
The following Regular Expression extracts the 3rd string:
(?:[^»]+?»){3}\s*(.+?)\s*[\nÂ]
You can test it interactively here.
I haven't actually used re2 before so keep in mind possible syntax differences.

Informatica Code to SQL Code

I am transforming the following informatica code to SQL. I am encountering some issues and would appreciate help with the following code:
SUBSTR(COV_REINS_CONCAT_BK,INSTR(COV_REINS_CONCAT_BK,'|',1,3) +1,2)
That is, I am looking for the equivalent code to produce the same results in SQL Server.
I appreciate anyone's help!
SUBSTR's equivalent is SUBSTRING.
INSTR's equivalent is CHARINDEX, but it has the first 2 parameters reversed, and does not support the 4th parameter (occurrence).
The expression returns 2 characters after the third occurrence of | (pipe).
Example: It will return 'FG' for 'A|BC|DE|FGH'.
So the translation will be:
SUBSTRING(COV_REINS_CONCAT_BK,1+CHARINDEX('|',COV_REINS_CONCAT_BK,1+CHARINDEX('|'
,COV_REINS_CONCAT_BK,1+CHARINDEX('|',COV_REINS_CONCAT_BK))),2)

Regular expression in SQL Server 2005+

I am stuck with a regular expression in SQL server 2005+, i.e. I need a regular expression to validate a first name (which allows only alphabets,whitespaces and a .(dot)).
I tried with below query
SELECT PATINDEX('%[A-Z]%[a-z]%[.]%','John H. Wilson') as VALIDFIRSTNAME
But, this also fails in some cases. I'm unable to find a clear regular expression. Any assistance would be very much appreciated.
I have used patindex to recognise the given pattern. If the string doesn't match the pattern, then It should give 0 else it should give 1 or >1.
Thanks in advance.
You can't match mentioned condition with available patterns.
Try to follow this way.

Resources