I want to use arrayformula for my custom function if possible because I want to input a range of values
I also get this error: TypeError: Cannot read property "0" from null.
Also, this: Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls
var regExp = new RegExp("Item: ([^:]+)(?=\n)");
var matches=new regExp(input);
return matches[0];
}
Really appreciated some help
Edit:
Based on the second picture, I also try using this regex formula to find word start with "Billing address"
But for the first picture, I used regex formula to find word start with "Item"
The error appears the same for both custom function.
If you want to use a custom function which finds all the strings that start with Item or item and extracts the contents from after the finding, you can use the code provided below. The regular expression is checked by using the match() function and returns the desired result; otherwise, it will return null.
function ITEM(input) {
var regEx = /(?:I|i)tem\s*(.*)$/;
var matches = input.match(regEx);
if (matches && matches.length > 1) {
return matches[1];
} else {
return null;
}
}
If you want to use the RegExp like you did in the code you have shared, you should use \\ instead of \.
For checking and verifying the regular expressions you can use this site.
The Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls. error message you are getting is due to the fact that you are trying to call the custom function on too many cells - for example dragging the custom function on too many cells at once. You can check more about this error message here.
Related
I have an angular app using the mongodb sdk for js.
I would like to suggest some words on a input field for the user from my words collection, so I did:
getSuggestions(term: string) {
var regex = new stitch.BSON.BSONRegExp('^' +term , 'i');
return from(this.words.find({ 'Noun': { $regex: regex } }).execute());
}
The problem is that if the user type for example Bie, the query returns a lot of documents but the most accurated are the last ones, for example Bier, first it returns the bigger words, like Bieberbach'sche Vermutung. How can I deal to return the closests documents first?
A regular-expression is probably not enough to do what you are intending to do here. They can only do what they're meant to do – match a string. They might be used to give you a candidate entry to present to the user, but can't judge or weigh them. You're going to have to devise that logic yourself.
I'm quite new to Jmeter and already spent numerous hours to figure it out.
What i'm trying to achieve:
Using Post Processor Regex Extractor I wrote a regex that returns me several values (already tested it in www.regex101.com and it's working as expected). However, when I do this in Jmeter, I need to provide MatchNo. which in this case will only return to me one certain value. I sort of figured it out that negative digit in this field (Match No) suppose to return all values found. When I use Debug Sampler to find out how many values are returned and to what variables they are assigned, I see a lot of unfamiliar stuff. Please see examples below:
Text where regex to be parsed:
some data here...
"PlanDescription":"DF4-LIB 4224-NNJ"
"PlanDescription":"45U-LIP 2423-NNJ"
"PlanDescription":"PMH-LIB 131-NNJ"
some data here...
As I said earlier, at www.regex101.com I tested this with regex:
\"PlanDescription\":\"([^\"]*)\"
And all needed for me information are correct (with the group 1).
DF4-LIB 4224-NNJ
45U-LIP 2423-NNJ
PMH-LIB 131-NNJ
With the negative number (I tried -1, -2, -3 - same result) at MatchNo. field in Jmeter Regex Extractor field (which Reference Name is Plans) at the Debug Sampler I see the following:
Plans=
Plans_1=DF4-LIB 4224-NNJ
Plans_1_g=1
Plans_1_g0="PlanDescription":"DF4-LIB 4224-NNJ"
Plans_1_g1=DF4-LIB 4224-NNJ
Plans_2=45U-LIP 2423-NNJ
Plans_2_g=1
Plans_2_g0="PlanDescription":"45U-LIP 2423-NNJ"
Plans_2_g1=45U-LIP 2423-NNJ
Plans_3=PMH-LIB 131-NNJ
Plans_3_g=1
Plans_3_g0="PlanDescription":"PMH-LIB 131-NNJ"
Plans_3_g1=PMH-LIB 131-NNJ
I only need at this particular case - Jmeter regex to return 3 values that contain:
DF4-LIB 4224-NNJ
45U-LIP 2423-NNJ
PMH-LIB 131-NNJ
And nothing else. If anybody faced that problem before any help will be appreciated.
Based on output of the Debug Sampler, there's no problem, it's just how RegEx returns the response:
Plans_1,Plans_2,Plans_3 is the actual set of variables you wanted.
There should also be Plans_matchNr which should contain the number of matches (3 in your example). It's important if you loop through them (you will loop from 1 to the value of this variable)
_g sets of variables refer to matching groups per matching instance (3 in your case). Ignore them if you don't care about them. They are always publish, but there's no harm in that.
Once variables are published you can do a number of things:
Use them as ${Plans_1}, ${Plans_2}, ${Plans_3} etc. (as comment above noticed).
Use Plans_... variables in loop: refer to the next variable in the loop as ${__V(Plans_${i})}, where i is a counter with values between 1 and Plans_matchNr
You can also concatenate them into 1 variable using the following simple BeanShell Post-Processor or BeanShell Sampler script:
int count = 0;
String allPlans = "";
// Get number of variables
try {
count = Integer.parseInt(vars.get("Plans_matchNr"));
} catch(NumberFormatException e) {}
// Concatenate them (using space). This could be optimized using StringBuffer of course
for(int i = 1; i <= count; i++) {
allPlans += vars.get("Plans_" + i) + " ";
}
// Save concatenated string into new variable
vars.put("AllPlans", allPlans);
As a result you will have all old variables, plus:
AllPlans=DF4-LIB 4224-NNJ 45U-LIP 2423-NNJ PMH-LIB 131-NNJ
How do I count the number of samples/values returned by jmeter extractors.
I am using regex to get the list of links to a variable using regex extractor.
By debug sampler shows that there many values returned. until like 9_g1
PlanLinksArray_9_g=1
PlanLinksArray_9_g0=/hix/admin/planmgmt/viewqhpdetail/gLe8eM5psNUTqo8aYXo20w
PlanLinksArray_9_g1=/hix/admin/planmgmt/viewqhpdetail/gLe8eM5psNUTqo8aYXo20w
How can i get the count of this to a variable in Jmeter??
AS per:
http://jmeter.apache.org/usermanual/component_reference.html#postprocessors
it will be called:
PlanLinksArray_9_matchNr : the number of matches found; could be 0
You can get extracted variables count as ${PlanLinksArray_matchNr} it will hold the number of variables like:
PlanLinksArray_1
PlanLinksArray_2
PlanLinksArray_3
etc.
If you need to include match groups as well, like
PlanLinksArray_1_g
PlanLinksArray_1_g0
PlanLinksArray_1_g1
etc.
you'll have to do some scripting.
Add a Beanshell PostProcessor after your Regular Expression extractor
Put the following code into the PostProcessor's "Script" area
JMeterVariables vars = new JMeterVariables();
Iterator iterator = vars.getIterator();
int counter = 0;
while (iterator.hasNext()) {
Map.Entry e = (Map.Entry) iterator.next();
if (e.getKey().startsWith("PlanLinksArray")) {
counter++;
}
}
vars.put("extractedValues", String.valueOf(counter));
Number of variables which names start with "PlanLinksArray" will be available as ${extractedValues} variable
See How to use BeanShell: JMeter's favorite built-in component guide for more Beanshell tips and tricks.
I'm using Google Analytics Api with Apps Script and trying to filter some pages using regular expressions.
But always this error displayed.
Invalid value '{filters=ga:pagePath=~(/burm)|(/4assort)|(/mkn)|(/apl)|(/grp)|(/pea)|(/arakawa)}'. Values must match the following regular expression: 'ga:.+'
I tried some simple expression, for example,
var ReEx ='(\/abc)|(\/def)';
'filters':'ga:pagePath=~'+ ReEx
Is there something incorrect expressions in my code?
Therefore I tried to filter a single page. and it still same error returned.
function getCart(){
return '/ShoppingCart.html';
}
var Cart = {
'filters':'ga:pagePath=~'+getCart()
}
var results = Analytics.Data.Ga.get(//
tableId, // Table id (format ga:xxxxxx).
startDate, // Start-date (format yyyy-MM-dd).
endDate, // End-date (format yyyy-MM-dd).
Cart
);
sheet.getRange(3, 7).setValues(results.getRows());
I solved it by naming pagepath in small caps also make sure there are no spaces:
ga:pagepath==/prodcuts/motors
or
ga:pagepath=~/prodcuts/motors
At the contact form I have a field name as Extension (new_ext). and at the onChnage event I want to do check weather the user has enter the number or anything else. I have the following piece of code.
function formatPhone(phonenum)
{
var ext =phonenum.getEventSource().getValue();
var reg = /^[0-9]$/;
if(ext.match(reg))
{
alert("Valid");
}
else
{
alert("invalid");
}
}
It returns me always invalid even if I enter a letter or a number or both.
I want to seek your kind suggestions and help regarding this.
Try this one "^\d+$", just check for null values before if you need to.
Already asked here Regex allow a string to only contain numbers 0 - 9