Regular expression multiple cut on string selenium ide - selenium-ide

My basic string structure :
Gestion des tickets - Compte 5 - SARL PROJET DE BLI[Commercial: SNOW Jon]
Explanation of decompose string :
- "5" : an ID
- "SARL PROJET DE BLI" : a company name
- "SNOW Jon" : the full name of a sale agent, composed by "last name" + "first name"
What I've done and works :
store my structured string : storeText | css=h1 | h13
store the ID : storeEval | storedVars['h13'].split(' ')[5] | final_id
What I really needs : 2 regular expressions for store the 2 last one, company name and full name of sale agent. I need only what is between "" whithout useless space on begin and end.
I already try something like this :
storeEval | storedVars['h13'].match(/- \/((?:.|<br />)*?) [/) | final_company
But don't works ... perhaps the space ...
For company name i want store ALL BETWEEN "- " AND " ["
same for the full name : store ALL BETWEEN ": " AND "]"
Did someone have a solution ? I'm not very good with regular expression... in english too :p

I finally find it myself, i try this and it works:
storeEval | storedVars['h13'].match(/- ([a-zA-Z ]+) [/)[1] | fi_rs
storeEval | storedVars['h13'].match(/\: ([^\]]+)\]/)[1] | fi_rs2
Bye.

Related

Azure Log Analytics for Postgres Flexible Server

Just trying to use a pre-existing "Slowest queries - top 5" from Azure log analytics for postgres flexible server. The query that is provided is:
// Slowest queries
// Identify top 5 slowest queries.
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DBFORPOSTGRESQL"
| where Category == "QueryStoreRuntimeStatistics"
| where user_id_s != "10" //exclude azure system user
| summarize avg(todouble(mean_time_s)) by event_class_s , db_id_s ,query_id_s
| top 5 by avg_mean_time_s desc
This query results in the error :
'where' operator: Failed to resolve column or scalar expression named 'user_id_s'
If the issue persists, please open a support ticket. Request id: XXXX
I am guessing that something is not configured in order to utilize the user_id_s column. Any assistance is appreciated.
I am expecting you are checking the integer value 10 is not equal to the user_id_s.
In your KQL query user_id_s != "10" .
Thanks # venkateshdodda-msft I am adding your suggestion to help to fix the issue.
If you are using integer in a KQL make sure to remove the " " double quotes.
# using as a integer
| where user_id_s != 10
Or convert the integer into string by using
# converting into string
| extend user_id_s = tostring(Properties.user_id_s)
| where UserId in ('10')
Modified KQL Query
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DBFORPOSTGRESQL"
| where Category == "QueryStoreRuntimeStatistics"
# using as a integer
| where user_id_s != 10 //exclude azure system user
| summarize avg(todouble(mean_time_s)) by event_class_s , db_id_s ,query_id_s
| top 5 by avg_mean_time_s desc
Reference:
Operator failed to resolve table or column expression
Converting integer to string

MYSQL WORKBENCH: Separating last 2 characters from a column

I am trying to remove the last two characters from a column. The current column that I am targeting has already been created by separating a string, but as you'll see below, it wasn't successful for the 'City' column.
This is how the original looks:
enter image description here
This is what I've been able to output from my code:
| StreetNumber | Street | **City** | State |
|----------------------------------------------------------------------|
| 1808 | FOX CHASE DR | **GOODLETTSVILLE TN** | TN |
| 1832 | FOX CHASE DR | **GOODLETTSVILLE TN** | TN |
| 2005 | SADIE LN | **GOODLETTSVILLE TN** | TN |
actual pic:enter image description here
This is my code:
select substring_index(substring_index(OwnerAddress, ' ', 1), ' ', -1) as StreetNumber,
substring(OwnerAddress, locate(' ', OwnerAddress),
(length(OwnerAddress) - (length(substring_index(OwnerAddress, ' ', 1))
+ length(substring_index(OwnerAddress, ' ', -2))))) as Street,
substring(substring_index(OwnerAddress, ' ', -2) from 1 for length(OwnerAddress)-2) as City,
substring_index(OwnerAddress, ' ', -1) as State
from nashhousing;
The goal is to remove the state abbreviations from the 'City' column because there's a state column already. I thought I could simply -2 for the last two characters but obviously, that didn't work. I hope I've explained my situation clearly, but if not, please let me know. I don't want to give up on this situation but I've been on it for 5 hours already and can't source a solution. Please help and thank you in advance!
To directly answer your question, you are using the wrong field and value for the length portion of the SUBSTRING on the city field.
This should correct your issue:
substring(substring_index(OwnerAddress, ' ', -2), 1, substring_index(OwnerAddress, ' ', -2) - 2) as City,
Or even
substring_index(substring_index(OwnerAddress, ' ', -2), ' ', 1) as City
Please Note:
The major issue with doing things this way is you are assuming every entry is formatted the same, and you're not taking into account cities with two names. ie New York City, Los Angeles, San Francisco, etc.
This is something that you likely need to parse outside of MySQL. Since you only need it to be parsed, you could likely write a decent enough RegEx to handle the majority of the cases. However, if accuracy is your top priority, I would recommend geocoding the data.

PowerShell - xml files with conflicting multiple namespaces on the same element name

Related to PowerShell 5.1
I was playing around with XML to show how to handle conflicting namespaces. Here's the example I created:
<Employees>
<ms:Employee id='1' xmlns:ms="MicrosoftEmployees">
<FirstName>Bill</FirstName>
<LastName>Gates</LastName>
</ms:Employee>
<ms:Employee id='2' xmlns:ms="MicrosoftEmployees">
<FirstName>Paul</FirstName>
<LastName>Allen</LastName>
</ms:Employee>
<ap:Employee id='1' xmlns:ap="AppleEmployees">
<Name>Steve Jobs</Name>
</ap:Employee>
<ap:Employee id='2' xmlns:ap="AppleEmployees">
<Name>Steve Wozniak </Name>
</ap:Employee>
</Employees>
The scenario might be combining data from two different companies.
PowerShell demonstration program:
cls
$filename = "c:\XMLClass\IntroSamples\Sample05_Simpler_Namespace.xml"
[xml]$xmlDoc = Get-Content $filename
$xmlDoc.Employees.Employee[0]
$xmlDoc.Employees.Employee[1]
$xmlDoc.Employees.Employee[2]
$xmlDoc.Employees.Employee[3]
Output:
id ms FirstName LastName
-- -- --------- --------
1 MicrosoftEmployees Bill Gates
2 MicrosoftEmployees Paul Allen
1
2
Is there anyway to get a more logical output?
It seems like PowerShell locks into the first schema it sees for the Employee element, then cannot show the Name element of the Apple employees. This actually makes sense, but I was just checking to see if there is something fancier to handle this that I might be missing.
I know I could use SelectSingleNodes and XPath, but was just trying to see if and how PowerShell could handle this "out of the box".
If I reverse the code:
$xmlDoc.Employees.Employee[2]
$xmlDoc.Employees.Employee[3]
$xmlDoc.Employees.Employee[1]
$xmlDoc.Employees.Employee[0]
Then the output is:
id ap Name
-- -- ----
1 AppleEmployees Steve Jobs
2 AppleEmployees Steve Wozniak
1 ms:Employee
2 ms:Employee
Use format list to see all the properties. Format-table doesn't handle different sets of properties well.
$xmldoc.employees.employee | format-list
id : 1
ms : MicrosoftEmployees
FirstName : Bill
LastName : Gates
id : 2
ms : MicrosoftEmployees
FirstName : Paul
LastName : Allen
id : 1
ap : AppleEmployees
Name : Steve Jobs
id : 2
ap : AppleEmployees
Name : Steve Wozniak

How to remove new line when record empty in crystal report

Sorry if it duplicate or etc.
I want to display record in Crystal Report like
String1 | String2 | String3 | String4 |
------------------| 12345 |
------------------| 12345 |
String3 contain 4 field, field1-4
But my code did not work like that
String1 | String2 | String3 | String4 |
------------------| 12345 |
------------------| 12345 |
------------------|--------|
------------------|--------|
What i want to do is display record when it has some data, i have 4 record, if 1 or more record contain some data then other record will not create new line, so no space will be taken.
if {Table.Field1} = "0" then
""
else if {Table.Field2} = "0" then
""
else if {Table.Field3} = "0" then
""
else if {Table.Field4} = "0" then
""
else
{Table.Field1} & "<br>" & {Table.Field2} & "<br>" & {Table.Field3} & "<br>" & {Table.Field4}
Using Can Grow and Text Interpretation HTML Text on Crystal Report
one wayout would be using text fields with background colour enabled on it.
Basic idea is place the text fields with background that is matching the report and write supress conditions for text fields so as when there is no data then show else supress.
This will ensure that when there is no data then text field will cover the line which will give the impress that line is not printed.
Edit---------------------------------------------------------------
Now in below picture I have place a text field in between line and set the background color to white that matches my preiview.
Check the rectangle highlighted part at the end of the line
Now in preview you can see in looks like there is no line where the text field is placed.

find pattern relationships using rest cypher

how can I find pattern relationships using rest cypher?
My query running on terminal :-
MATCH (n)<-[:DEPENDS_ON*]-(dependent) RETURN n.host as Host,
count(DISTINCT dependent) AS Dependents ORDER BY Dependents
DESC LIMIT 1**
output is :-
+--------------------+
| Host | Dependents |
+--------------------+
| "SAN" | 20 |
+--------------------+
where as equivalent query with rest :-
String query = "{\"query\" : \"MATCH (website)<-[rel]-(dependent) " +
"WHERE TYPE(rel) = {rtype} RETURN website.host as Host," +
"count(DISTINCT dependent) AS Dependents ORDER BY Dependents DESC LIMIT 1" +
" \", \"params\" : {\"rtype\" : \"DEPENDS_ON*\"}}";
and output is empty(no records) !!!
Any help appreciated.
P.S- When we dont use "*" in our query everything goes ok. IE both queries give same result
In the second query you are passing the relationship type as "DEPENDS_ON*" which is incorrect since the asterisk is being included.
The asterisk is for allowing arbitrary length paths for the specified relationship but is not part of the type.