HP ALM query by name with spaces - hp-quality-center

I am trying to use HP ALM 11's REST API. So far I have been able to query stuff fine. Now I have hit a case where the name of the entity (a test folder) is with spaces: "WebView - New Thin UI"
{name['WebView - New Thin UI']}
If I specify the query like {name['WebView*']} it returns a bunch of test folders among which is also the one mentioned above.
However, if I use the full name including the spaces (The string gets escaped and spaces converted to +. I can see GET /qcbin/rest/domains/XXX/projects/XXX/test-folders?query=%7Bname%5B%27WebView+-+New+Thin+UI%27%5D%7D&page-size=max&start-index=1 HTTP/1.1 in the logs) I get no results (empty set, not an error).
I do not see how else I should specify the query criterion so that it would work.

Use double quotes instead of single quotes.
Following query works fine with my instance and returns single record.
http://hp.gaurav.com:8080/qcbin/rest/domains/DEFAULT/projects/TestProject/defects?query={name[="Sample query test"]}

Related

Remove http:// or https:// and Trailing / in NetSuite Saved Search

Let me preface this by stating very clearly that I am not a developer and I'm new to NetSuite formulas.
I have a NetSuite saved search that include the Web Address (field id: {url})
I need to remove everything except the main part of the domain (end result should look like abc.com).
I have attempted to use REPLACE({url}, 'http://[,' ']) unsuccessfully.
I have also attempted various LTRIM, RTRIM, TRIM formulas without luck.
I found some information on using REGEXP_SUBSTR, but wasn't successful there either.
I was able to accomplish my goal in Excel using Excel string functions MID, LEN, and RIGHT, but that doesn't seem to translate in NetSuite.
I'd love some assistance.
REGEXP_SUBSTR({url}, '//(.)+') --> get substring starting with //
REPLACE({text}, '/') --> replace / with nothing
The final formula is:
REPLACE(REGEXP_SUBSTR({url}, '//(.)+'), '/')
Jala's answer doesn't seem to work for URLs such as https://stdun7.wixsite.com/stdunstansparish where it returns stdun7.wixsite.comstdunstansparish
In your saved search create a Forumula (Text) field with the following formula
REGEXP_REPLACE({url},'(^http[s]?://)([a-zA-Z0-9.-])(/?.)', '\2')
I'll break down the arguments for the REGEXP_REPLACE function and how it all works...
First argument - {url} the Field containing the url information to parse
Second argument - regexp string
Third argument = replace regexp string
the regexp string has parentheses to denote capture groups of portions of the regular expression.
The first capture group captures the protocol portion of the URL.
The second capture group captures the next part, all permissible hostname characters until the end of the string, or until a '/'
The third capture group captures the remaining portion of the string.
The replace string is used to prepare the return value of the REGEXP_SUBSTR function. Since the entire url is matched by the regexp, the entire string will be replaced by this expression, referencing the second capture group. (aka the hostname)
Since you say you're new to NetSuite formulas, I'll note that those functions are based on Oracle PL/SQL so if you want additional info or examples of how they work beyond what NetSuite provide, sometimes it's instructive to just google things like "pl/sql REGEXP_SUBSTR" etc. to get additional documentation how how they work.
Another good resource is regex101.com, a helpful site to test regular expressions in advance....

How to remove "/"/"" from data stored in firebase with App Inventor

When adding data with the block call.StorageValue, the string is saved in firebase with "/" before and after the string,
There does not seem to be any block to remove it, How can I do it?
It's a normal firebase function that allows to separate the values and read them as such.
Example :
on Firebase, "\"English-EN\"" is a single value sent from the app as English-EN
and "[\"863674037411046\",\"863674037411046\",\"863674037411046\",\"863674037411046\"]" is a list of numbers sent as 863674037411046.
Try to retrieve the value with a button and to a simple label and you should see that it's displayed without the extra characters.
Source:check my app "harpokrates". I've made it as a firebase DB management demo and it uses nothing else. All values are stored as you describe and are retrieved just fine, without extra symbols or any need to trim the text.
ps:However if you do have extra symbols at some point, check your use of lists and lists of lists that might generate excessive "\" if you made a mistake somewhere. You can also use the "trim" or "split text" blocks but that would be bad practice. Finding the code error is best.
This is likely an escape character that escapes the special character " (quotation marks). This is common practice to use \ as an escape character to indicate that the next character has special meaning, in this case it is not the start or end of a string but actually part of it.
As such you can't actually remove it (just the escape character) and should consider how you got a quotation mark in the string to begin with.
You should however be able to remove the entire quotation mark \"

Compare strings ignoring case

I am trying to find entities (Tags) in the database via their Name property, where it is important to ignore the case (When database is searched and the Database contains a Tag with the name Database, that one should be returned). Right now, my code looks like this:
public IEnumerable<db.Tag> FindByNames(IEnumerable<string> tagNames)
{
return this.DatabaseContext.Tags
.Where(tag => tagNames.Contains(tag.Name));
}
Obviously, this one is case sensitive. I have tried to provide StringComparer.OrdinalIgnoreCase as comparer to the Contains method, but got a warning during execution that the expression could not be translated and would be executed in code rather than in the database (I don't remember the exact message, I will edit as soon as I am back on my development machine). I can live with that if I have to, but it would be nice to know how to let the database do the work in this case. Is it possible?
No change should be necessary. SQLite's "LIKE" is already case-insensitive.
The default behavior of the LIKE operator is to ignore case for ASCII characters.
(cref https://www.sqlite.org/pragma.html#pragma_case_sensitive_like and Case sensitive and insensitive like in SQLite)
Of course, you can always use .FromSql() to get the exact query you want. Example:
context.Tags.FromSql("SELECT * FROM tags WHERE name LIKE '%{0}%'", tagName)

URL just removes parameters

I've created an API for use on my website.
The API I made strips everything using mysql_real_escape_string then puts it into the database.
But the problem I'm having is the URL that my php scripts are using to access the API is cut short sometimes...
Which I have narrowed down to one of the parameters...
When its Ford Mondeo 22' the URL that is passed to simplexml_load_file is
http://mydomain.com/api/create.xml?api_number=brho15p6z1dhqwf5tsff&env=live&number=AJ20023232&title=Ford Mondeo 22'&image=http://mydomain.com/wp-content/uploads/2012/10/914955-150x150.jpg
but the API reports back the URL accessed as
http://mydomain.com/api/create.xml?api_number=brho15p6z1dhqwf5tsff&env=live&number=AJ20023232&title=Ford
If I remove the single quote then everything works fine, any idea how to correct this I suspect there's something I've overlooked when passing variables in the URL
It is the spaces in the "Ford Mondeo 22'" value that is causing the problem. You cannot have a spaces in the URL. You need to use escape characters. The encoded version of the parameter should be
Ford%20Mondeo%2022'
%20 is the escape character for space
I.e. the whole URL should read as follows:
http://mydomain.com/api/create.xml?api_number=brho15p6z1dhqwf5tsff&env=live&number=AJ20023232&title=Ford%20Mondeo%2022'&image=http://mydomain.com/wp-content/uploads/2012/10/914955-150x150.jpg
EDIT:
Your comment indicates that you use PHP. In PHP, you can use urlencode($foo) and urldecode($foo) to switch between the normal string and the encoding string.

ASP.NET default regular expression for users' passwords

What is the default regular expression used by asp.net create user wizard?
According to the MSDN documentation, it should be something like this:
Regular Expression: #\"(?:.{7,})(?=(.*\d){1,})(?=(.*\W){1,})
Validation Message: Your password must be 7 characters long, and contain at least one number and one special character.
However, it does not work as it does not accept something like 3edc£edc, which is actually accepted when using the default create user wizard.
Any idea about how can I get this regular expression?
The error is in the ?: in (?:.{7,})(?=(.*\d){1,})(?=(.*\W){1,}) that is "consuming" the fist seven characters or more characters. It should be ?= OR you can invert the order: (?=(.*\d){1,})(?=(.*\W){1,})(?:.{7,})
Just change the order
^(?=(.*\d))(?=(.*\W)).{7,}
I additionally removed the {1,} and anchored it to the start of the string and you don't need a group around the last part
See it here on Regexr

Resources