I am trying to use simple expression inside jsonpath . I tried using built in operators such as 'contains','starts with' inside jsonpath to do a comparison with a header value.
I have tried using the contains operator and that works, but the starts with operator fails
What works -
.jsonpath("$.configs[?(#.mask contains '${header.mask}')]")
what does not work
.jsonpath("$.configs[?(#.mask starts with '${header.mask}')]")
starts with does not work..for what reason I dont know..but then using a regex as shown below works
.jsonpath("$.configs[?(#.mask =~ /^\\${header.fileMask}.*?/i)]")
Related
I am automating a page using selenium with java and trying to use a case insensitive xpath with the help of translate function as follows.
driver.findElement(By.xpath("//a[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'tools')]")).click();
'tools' text exists on the page as 'Tools'. [T as caps]
Now my question is,
What does '.,' means in the above code?
Using 'tools' in place of '.,' gives all the //a links. Reason?
Whenever I use 'Tools' instead of 'tools' in the above code, it does not work.
Someone help me here.
image 1
image 2
Now my question is,
What does '.,' means in the above code?
Using 'tools' in place of '.,' gives all the //a links. Reason?
Whenever I use 'Tools' instead of 'tools' in the above code, it does not work.
The dot step is an abbreviated syntax, from the specs:
. selects the context node
Because it's used as parameter for a function that expects a string, will be casted by the means of string() function.
The string 'tools' always contains the string 'tools', thus you are not filtering any selected a element when you used instead of .
In the other hand, any lowercase string will never contain the string 'Tools', so you won't be able to select anything.
I am trying to set camel Header value using below Expression
.setHeader("amqName").simple("${amqAddressMap.get(header.userTypeID)}", String.class)
where amqAddressMap is an array list and passing header value as argument but it shows invalid expression error
is there any way to execute the code without using using processor class
To access ArrayList inside exchange we need to set it as a property
setProperty("amqAddressMap", constant(amqAddressMap))
So that we can access it using EL like
${exchangeProperty.amqAddressMap.get(${header.userTypeID})}
I'm creating a javascript regex to match queries in a search engine string. I am having a problem with alternation. I have the following regex:
.*baidu.com.*[/?].*wd{1}=
I want to be able to match strings that have the string 'word' or 'qw' in addition to 'wd', but everything I try is unsuccessful. I thought I would be able to do something like the following:
.*baidu.com.*[/?].*[wd|word|qw]{1}=
but it does not seem to work.
replace [wd|word|qw] with (wd|word|qw) or (?:wd|word|qw).
[] denotes character sets, () denotes logical groupings.
Your expression:
.*baidu.com.*[/?].*[wd|word|qw]{1}=
does need a few changes, including [wd|word|qw] to (wd|word|qw) and getting rid of the redundant {1}, like so:
.*baidu.com.*[/?].*(wd|word|qw)=
But you also need to understand that the first part of your expression (.*baidu.com.*[/?].*) will match baidu.com hello what spelling/handle????????? or hbaidu-com/ or even something like lkas----jhdf lkja$##!3hdsfbaidugcomlaksjhdf.[($?lakshf, because the dot (.) matches any character except newlines... to match a literal dot, you have to escape it with a backslash (like \.)
There are several approaches you could take to match things in a URL, but we could help you more if you tell us what you are trying to do or accomplish - perhaps regex is not the best solution or (EDIT) only part of the best solution?
I'm being stumped by something that should be trivial.
I've got an xml document, which is split using cSplitter using XPath which works fine, but then I want to set headers with values from the split document.
I've got a cSetHeader component with the Language set to XPath and the valid xpath. However, it returns the value as a NodeList object, when I need a string.
If I use an XPath expression that returns a string, it gives an exception as it can't convert to NodeList.
How, in Talend, do I configure the XPath expression to return a string. It seems ok if you're writing the camel directly, as there is a parameter, but I can't see how it is done in Talend.
Thanks!
I've figured it out...
As it's a code generator, talend puts in the .xpath( ... ) whatever you type in the field - so if you want it to generate a string you put
"/your/xpath/here", java.lang.String.class
in the cSetHeader xpath field and the code generator puts your xpath string with the requested class in the right place!
Easy! Now why didn't I think of that earlier...?
I have developed a interpreted programming language. It is strongly based on C. The problem is, I want to add a foreach directive and have no clue how to.
I am using Bison and Flex as the parser and lexer generator.
In your grammar, you'd want an expression that is something like the following:
foreach := foreach ( name in name ) { statements }
When you parse this, you should be able to translate it directly into a while loop in your AST with an additional statement that assigns a variable at the beginning.
This seems to me the simplest way to do it, but will probably have limitations with multiple iterable data-types (e.g. a list vs. an array). In this case, you may want to consider consolidating all iterables so that they have a consistent method to obtain the next element.