Does the JSTL <c:out> tag handle an EL arithmetic operation or just spit out String? - jstl

I have an EL expression ${4+(param.a)*4} in a jsp.
Will changing it to the following line of code do the arithmetic operation first then spit out the result as string or evaluate the whole expression as string first?
<c:out value='${4+(param.a)*4}'/>
I want to do the arithmetic operation 1st and then output the result as string.

Arithmetic operation first and gives you the result which will be printed in html element.

Related

Length of Assign variable issue in freemarker

I am using freemarker ..want to find the length of assign variable ..i used size and length function ..but it fails and returns the error ..Please help me in how to find length of the assign variable
Please find the below code i have tried...
Input data --- cusID="a-1242" -- I want to split input data by - and want to store in separate variable through assign function
<#list (it.#CusID[0]!"")?split("-") as c><#if ((c?index) ==0)>
<#assign first>${c}</#assign>
<#assign firstlen = c?size>
</#if>
</#list>
Above code firstlen is used to find the length but it fails to find length
ERROR MESSAGES find below
For "?size" left-hand operand: Expected an extended-hash or sequence
or extended collection, but this has evaluated to a markup_output
(wrapper: f.c.TemplateXMLOutputModel):
As the error message says, first stores XML markup, not just a plain text string. You can't get the length of markup with ?length, as it's not obvious what that means (like if the content of which XML elements matter, what if you have an entity reference, etc.). The reason it's markup is that <#assign first>...</#assign> is not a normal assignment, it's for capturing output, and you are using XML output format. Instead, use normal value assignment: <#assign first = c>. Now first will have the same type as c, string.

Incorrect expression evaluation with expr object in Pure Data

I'm trying to print string message once the expression is true, right now the output still prints a message though the expression is false.
Actually there is no problem with your expression, but the subsequent dataflow. The bang object [bng] converts any input to a bang message. Even though the expression is correct, the output 0 and 1 will both be converted into a bang. the bang is then printed into the console as "text":bang.
Replace the bang GUI with a [select 1] object and you are almost there.
This is a more Pd-like syntax:
Also: Please read Is there any reason to use vanilla Pure Data instead of Pd-extended?

Replacing chars in string

I have this code:
inspect w-string1 replacing all x'C48D' by 'c'
But I got this error by compiler
Operand has wrong size
Is there any solution how to replace more chars by one char thru inspect command. Or I must do it by myself via perform loop?
When using the INSPECT statement, both strings must be the same length. The only way to replace multiple characters by a different number of characters is to write your own loop to do it.

How do I use a regular expression to match a number as an integer?

When I match a number using a regular expression I get it as a string:
?> 'TestingSubject2981'.match /\d+$/
=> #<MatchData "2981">
Is it somehow possible to get the number as an integer without some to_is?
The issue is that regular expressions only work on strings, not on other data types.
A regex has patterns to match numbers, but those still only find the characters that represent the number, not the binary values that we'd use for math. Once the engine returns the matches, they're still characters, so we have to use to_i to convert them to their binary representations.
MMM-kay?
Regular expressions are not supposed to convert strings to integers (or any other class for that matter). The only way I can see is using the String#to_i method. And I can't see why you would avoid it.
You can also use to get number from string:
'TestingSubject2981'.scan(/\d+/)[0].to_i

Using parentheses in strings of text make xpath fail

My question is this: is it possible to write an xpath in which parentheses are interpreted as part of a string?
My selenium script keeps failing as soon as I use parentheses in a contains function.
For example:
//li/div/span[contains(text(),"Komkommer (BONUS)")]
I have the same problem. It has to do with encoding. Your parenthesis string may have different encoding than the comparison base.

Resources