My formula works fine in most cases, but I need to stop it from adding the asterisk if the {SAMPLEPARAM.PA_NAME} = "Methylene Chloride". How can I achieve this behavior?
if {METHOD.ME_TYP} ='COFA'
then '* '+ {SAMPLEPARAM.PA_NAME}
else if (IsNull ({METHOD.ME_TYP}) or {METHOD.ME_TYP} = ' ')
then {SAMPLEPARAM.PA_NAME}
else {SAMPLEPARAM.PA_NAME}
If you want "Methylene Chloride" to not have an asterisk, all you have to do is tell the code to skip over if it finds that specific string.
At the same time, simplify your code by removing the part when you check {METHOD.ME_TYP}. There are three branches in your code, but the last two are the same. The ELSE IF does nothing useful:
IF ({METHOD.ME_TYP} = 'COFA') AND ({SAMPLEPARAM.PA_NAME} <> "Methylene Chloride")
THEN '* ' + {SAMPLEPARAM.PA_NAME}
ELSE {SAMPLEPARAM.PA_NAME}
Related
Look at the query and result generated in sqlplus :
SELECT
plan_line_id,
LPAD (a.plan_operation || ' ' || a.plan_options,
LENGTH (a.plan_operation || ' ' || a.plan_options) + a.plan_depth * 3
) OPERATION,
a.plan_cost COST,
output_rows "ROWS"
FROM gV$SQL_PLAN_MONITOR a
WHERE sql_id = '8gan9d0z7bzhm'
Looks pretty cool doesn't it ;)
And the same result in grid report :
Apex 21 removes all spaces generated by lpad function. The same problem is with classic report and classic grid :( any idea why ?
You'll have to use a character which can be correctly interpreted by your browser - instead of a space, use a non-breaking space, the   character.
Something like this (I'm using the # character in the CTE, which is then replaced by :
WITH
temp
AS
(SELECT plan_line_id,
LPAD (
a.plan_operation || ' ' || a.plan_options,
LENGTH (a.plan_operation || ' ' || a.plan_options)
+ a.plan_depth * 3,
'#') OPERATION, --> here
a.plan_cost COST,
output_rows "ROWS"
FROM a1_test a
WHERE sql_id = '9p4xcx2gd8u49')
SELECT plan_line_id,
REPLACE (operation, '#', ' ') operation, --> here
cost,
"ROWS"
FROM temp
Turn "Operation" column's **Escape special characters" property OFF.
The result is then
Not as pretty as you'd want it to, but it is better than what you currently have.
I have a string:
s='articles[zone.id=1].comments[user.status=active].user'
Looking to split (via split(some_regex_here)). The split needs to occur on every period other than those inside the bracketed substring.
Expected output:
["articles[zone.id=1]", "comments[user.status=active]", "user"]
How would I go about this? Or is there something else besides split(), I should be looking at?
Try this,
s.split(/\.(?![^\[]*\])/)
I got this result,
2.3.2 :061 > s.split(/\.(?![^\[]*\])/)
=> ["articles[zone.id=1]", "comments[user.status=active]", "user"]
You can also test it here:
https://rubular.com/r/LaxEFQZJ0ygA3j
I assume the problem is to split on periods that are not within matching brackets.
Here is a non-regex solution that works with any number of nested brackets. I've assumed the brackets are all matched, but it would not be difficult to check that.
def split_it(s)
left_brackets = 0
s.each_char.with_object(['']) do |c,a|
if c == '.' && left_brackets.zero?
a << '' unless a.last.empty?
else
case c
when ']' then left_brackets -= 1
when '[' then left_brackets += 1
end
a.last << c
end
end.tap { |a| a.pop if a.last.empty? }
end
split_it '.articles[zone.id=[user.loc=1]].comments[user.status=active].user'
#=> ["articles[zone.id=[user.loc=1]]", "comments[user.status=active]", "user"]
I have a line of code that is saying that there is invalid syntax in my print statement. Does anyone know about how to fix this? I've tried deleting the parentheses and have tried changing the +'s to ,'s.
print(stockName[random] + ' - $' + Names[0, amod] + ' : You have ' + x + ' of this stock')
If you use ' x ' with + operator it should be a string else you should use coma.
How to write a regular expression for a text field which accepts all characters except a comma (,) and do not accept a white space at both the ends? I have tried
[^,][\B ]
but no use
like 'product generic no' instead of 'product,generic,no' or ' product generic no '
I suggest a solution without regular expression. As you said you're using JS so the function is in JavaScript:
function isItInvalid(str) {
var last = str.length - 1;
return (last < 2 ||
str[0] == ' ' ||
str[last] == ' ' ||
str.indexOf(',') != -1);
}
EDIT: Just made it a bit more readable. It also checks if the string is at least 3 chars.
Something like below:
/^\S[^,]*\S$/
Using a Perl regular expression
/^\S[^,]*\S$/
This should work from 2 characters up, but fails in the edge case where the string has only one non-comma character. To cover that too:
/^((\S[^,]*\S)|([^\s,]))$/
I am having a code as
$wrk = OC192-1-1-1;
#temp = split (/-/, $wrk);
if ($temp1[3] =~ /101 || 102 /)
{
print "yes";
} else {
print "no";
}
Output :
yes
Need to know why this is printing yes. I know for regular expression | is supported for OR operator. But need to know why || is giving as "yes" as output
It is because || will make regex match succeed by matching with nothing all the time.
So it is essentially matching $temp1[3] (which doesn't exist) with anyone of the following
"101 "
""
" 102 "
I added double quotes just for explanation.
/101 || 102 / regex tries to match '101 ', or '' (empty string), or ' 102 '.
Since empty string can always be matched, it always returns true in your condition.
In addition to the regex-relevant answer from #anubhava, note that: OC192-1-1-1 is same as 0-1-1-1, which is just "-3", therefore #temp evaluates to ( "", "3" )
And of course there's no such thing as $temp1