Regular expression evaluation with logical operator

Hi All,
I am bit confuse with expression evaluation with logical operator. I am trying to understand below expression.
eXa.getTrue() && eXa.getFalse() || eXa.getFalse() && eXa.getTrue() || eXa.getFalse() comes as false and True Count: 1 False Count: 3
As per understanding it should be true with True Count: 1 False Count: 3
it should execute 1st getTrue() and then 1stGetFalse() and then 2nd getfalse() and should skip 2nd getTrue() and execute 3rd fetFalse()
eXa.getTrue() && eXa.getTrue() || eXa.getFalse() && eXa.getTrue() || eXa.getFalse() comes as true and True Count: 2 False Count: 0
As per understanding it should be true with True Count: 3 False Count: 0
it should execute 1st 2 getTrue() and skip 1st getFalse() and then execute 3rd getTrue() and skip last getFalse().
eXa.getTrue() || eXa.getFalse() && eXa.getFalse() || eXa.getTrue() && eXa.getFalse() comes as true and True Count: 1 False Count: 0
As per understanding it should be true with True Count: 2 False Count: 2
it should execute 1st getTrue() and skip 1st getFalse() and then execute 2nd getFalse() and then execute 2nd getTrue() and then 3rd getFalse()
Please help me to understand above expressions.
Here is the methods definition:
private boolean getTrue() {
          trueCount++;
          boolean retrunValue = 4 > 3;
          return retrunValue;
private boolean getFalse() {
          falseCount++;
          boolean retrunValue = 3 > 4;
          return retrunValue;
Thanks for ur help

>
adding parenthesis to make order of ops more obvious. adding "?" to show un-executed calls.
(eXa.getTrue() && eXa.getFalse()) || (eXa.getFalse() && eXa.getTrue()) || eXa.getFalse()  comes as false and True Count: 1 False Count: 3
(T && F) = F
(F && ?) = F
(F) = F
F || F || F = F
(eXa.getTrue() && eXa.getTrue()) || (eXa.getFalse() && eXa.getTrue()) || eXa.getFalse()  comes as true and True Count: 2 False Count: 0
(T && T) = T
(? && ?) = ?
(?) = ?
T || ? || ? = T
eXa.getTrue() || (eXa.getFalse() && eXa.getFalse()) || (eXa.getTrue() && eXa.getFalse())  comes as true and True Count: 1 False Count: 0
(T) = T
(? && ?) = ?
(? && ?) = ?
T || ? || ? = T

Similar Messages

  • Regulare Expressions - Uses of logical operators

    I need to make use of logical operators within a regulare expression. (greater than, equal, etc.)
    It seems to me that java.util.regex.Pattern does not support that kind of expression. First of all: Is this true (If I am wrong with my assumption, how would the expression look like). Secondly: Which library does support this expression?
    Thanks in advance!

    Regular expressions deal with characters. In that context all characters are 'equal'. You better explain your question a helluva lot better than that.

  • Issue with logical operator using SetEnvIF in OHS

    We have a requirement to set constant value in ssl.conf (OHS) based on Request_URI & referrer. For example, if (Request_URI=/forms/base/login) and (Referer=http://example.com), then we need to set variable value with 1. Similarly we some more conditions. I am trying to use 'SetEnvIf', but it is not allowing to use logical operations (and, or, &, |).
    Can any let us know in resolving issues?

    Just to confuse matters, this problem is intermittent and I haven't been able to successfully replicate it in our Test environment.
    That would seem to indicate something else was going on in the DB that was interfering with the clear, but the logs aren't showing any errors, locks, etc that could have caused the problem.

  • Regular expression substitution with escaped $

    I'm looking to perform a substitution (along the lines of String.replaceAll()) that matches with the character $. I have tried $, \$, \\$, and variations thereof in the regex string utilizing String.replaceAll() and with a Pattern.compile(). In both cases I get an "Illegal repetition near index X" error. Anyone have suggestions as to escaping the $ character for regular expression substitutions?
    Edited by: dolcraith57 on Dec 6, 2007 11:18 AM

    It would help if you'd post details--e.g. original string and desired result, with an explanation of the rules.
    str1 = "a$1$2$b$";
    str2 = str1.replaceAll("\\$", "X"); // aX1X2XbX
    str3 = str1.replaceAll("\\d", "\\$"); // a$$$$$b$

  • [b]Parameter with logical operator.[/b]

    I have where clause in SQL like this :
    WHERE (Date#1 = '31-JAN-2005' AND Date#2 BETWEEN '01-JAN-2005' AND '31-JAN-2005')
    OR (Date#1 = '28-FEB-2005' AND Date#2 BETWEEN '01-FEB-2005' AND '28-FEB-2005')
    OR (Date#1 = '31-MAR-2005' AND Date#2 BETWEEN '01-MAR-2005' AND '31-MAR-2005')
    I will enter the value of column Date#1 in the range value such as Date#1 between '31-JAN-2005' and '31-MAR-2005'.
    How to use parameters with this WHERE clause?
    Note: Date#1, Date#2 is the column in the table.
    S. Vilas

    Vilas,
    You can implement this by using 3 parameters (one for Date#1 i.e., Date1; and two for Date#2 i.e., Date2From and Date2To) and a condition (i.e., Cond1):
    1)Date1: For Item "Date#1", with "=" condition operator
    2)Date2From: For Item "Date#2", with "=" condition operator
    3)Date2To: For Item "Date#2", with "=" condition operator
    4)Cond1: Item "Date1", condition "=", values ":Date1"; Group "OR"; Item "Date#2", Condition "Between" Values :Date2From and:Date2To
    Best wishes.
    Zahid

  • Regular expression breaks with \00 in input string

    I wrote the following code to illustrate the problem.
    Clearly the match should occur in both cases, but it does not occur if \00 is in the input string (within the < > ).
    I am not even searching for \00 or \01. This makes the regular expression match rather useless if you have text that contains data in hex form. I am using Labview 8.2. Is this a known bug? Is there a work around?
    Tammo
    Message Edited by Tammo on 03-06-2008 12:26 PM
    Message Edited by Tammo on 03-06-2008 12:26 PM
    Attachments:
    RegEx1.vi ‏56 KB
    BlockDiagram1.jpg ‏18 KB
    FrontPanel1.jpg ‏18 KB

    There was a brief discussion on this not too long ago.

  • Using Logic Express 8 with Logic Pro 7

    I have Logic Pro 7 academic version,but I would like to try Logic 8, so I was going to give express a shot. Will Logic Express 8 use my software instruments and plug-ins from Logic Pro 7?

    You know what? I can't help but to even be ashamed to be in any of the forums here in LE8. I got mine on Tuesday and, within minutes of the installation, I had "everything" set up and ready to go for the recordings that I do. Not one bump. It has been nothing but a virtual love fest with me and LE8! With all of the complaining and problems that people are having, I feel that I am definitely in a neighborhood where I am not welcome.
    Here's what I did. I looked at the options for creating a new song that we get when we want to create a new file (you have seen the prepared workspaces that LE8 gives you to choose from) and, because I only use "live" instruments (guitar, banjo, mandoline, 12 string guitar, classic guitar, and a fiddle--as well as my voice(), I just chose the selection for 8 live instruments. Now, I have read the forums for abou a year and the major complaint of the newbies is that they can't seem to get music "out" of LE and that it is almost impossible to "wrap their heads around" it. Well, Apple has answered the users with these automatic workspaces with the soundflow already set up. There is no installation of all those preferences and the personal existing hardware. No fidgeting there.
    So, as I sit here in pig heaven and grunt in imported mud with others of my own ilk, I am truly happy and hav not a single complaint.
    May the seas always move in your favor and be calm as the glass of a mirror.
    Anyse

  • Url with logical operator for filter

    hi all,
    maybe its a stupid question, but I didn't find any
    answer for this and I need urgent help:
    How do we build URLs with filter for more than 1 value.
    Is there a way to combine with Operators like AND / OR ??
    e.g something like this:
    url=url+"&FILTER_IOBJNM_2=ZZZD&FILTER_VALUE_2=(A OR B);
    how is this correctly solved ? May someone give me an example URL ?
    Thanks a lot.

    I am not too sure if you can do an OR in restricting a query either.
    For multiple values as restrictions - AND condition
    &FILTER)IOBJNM_1=ZCUSTOMER&FILTER_VALUE_1=SDN&FILTER_IOBJNM_2=ZCUSTOMER&FILTER_VALUE_2=SAP AND SO ON.
    I am not too sure but there must be a way to pass the range.
    For OR condition at runtime I am not sure if it is possible , I think you could exclude values but I am not too sure if it can be done either... anyone ?
    Arun

  • Regular Expressions problem with OPA

    hi,
    I have version OPA 10.2, when I try using regualr expressions it won't let you submit data and move onto the next screen.
    I've tried for example using the OPA hel's National Insurance number, I tried for a 6 digit number using:
    For a minimum of 6 digits:
    ^\D*(?:\d\D*){6,}$
    and I also tried:
    ^[0-9]{1,6}$
    None of them worked; is there something obvious I'm missing?
    Thanks

    Hello,
    Just tried this out and the two expressions worked as I would expect. I receive the error message as configured in the properties file and cannot progress to the next screen until I enter 6 digits or more. Is that different to the behaviour you are seeing? Also, have you tried using the debugger without screens? The error message would appear at the top of the debug window "Cannot set value of attribute 'test'. Reason: Invalid Value."
    Also, are you trying to validate a text attribute or a number attribute? Number attributes can be a little trickier since the regex appears to run against them after they're converted. So if the user enters "99", the regex validates against "99.0".

  • Extract values with Regular Expression

    How to extract values into [ ] using regular expression.
    With data As
    Select 'AAAAAA[10] AAA: 19C' Txt From Dual Union all
    Select 'XX[450]-10A' Txt From Dual Union all
    Select '[5]AVC19C' Txt From Dual Union all
    Select 'FVD[120]D2AC' Txt From Dual
    )I hope this return
    10
    450
    5
    120Thanks in advanced

    user11118871 wrote:
    Thanks for all.
    Hi BluShadow, can you explain what this is doing!?
    ThanksSure.
    Search for ----------------|           /------- Replace the found pattern in the search string with backreference 1
                         /------------\   /\       (the first thing backreferenced in the search string)
    regexp_replace(txt, '^.*\[(.*)\].*$','\1')
                         |\/\/\--/\/\/|
                         | \ \  /  \ \|
                         | | |  |  | |\- End of string
                         | | |  |  | |
                         | | |  |  | \- Any number of characters
                         | | |  |  |
                         | | |  |  \- Right square bracket (escaped)
                         | | |  |
                         | | |  \- any characters (backreferenced by round brackets)
                         | | |
                         | | \- Left square bracket (escaped)
                         | |
                         | \- Any number of characters
                         |
                         \- Start of stringEdited by: BluShadow on Jun 29, 2009 2:19 PM

  • Regular expression not working for adobe forms

    Hi,
    Iam using qtp for adobe forms and for some reason if i put in regular expression for apid value it doesn't recognise the object..there is nothing wrong with the regular expression as it is evaluated using regular expression evaluator in qtp 11.0....any ideas
    I got all the addins and everything and when i used regular expression for the top window it works but for any other object it doesn't

    Please try the code and see the problem. The regular expression is fine.
    I can replace the string with these and got results like this:
    import java.util.regex.Pattern;
    public class HtmlFilter implements TextFilter {
        private static String strTagPattern = "<\\s?(.|\n)*?\\s?>";
        private static int patternMode = Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.CANON_EQ;
        private static Pattern tagPattern = Pattern.compile(strTagPattern, patternMode);
        public String filter(String t) {
              if(t==null || t.length()==0) return "";
            String ret = null;
            return tagPattern.matcher(t).replaceAll("");
         public static void main(String[] args) {
              System.out.println(new HtmlFilter().filter(null));
              System.out.println(new HtmlFilter().filter(""));
              System.out.println(new HtmlFilter().filter("<P>abc def</P>"));
              System.out.println(new HtmlFilter().filter("<P>&#25105;&#22269;&#30707;&#27833;&#20379;&#24212;&#23433;&#20840;&#31995;&#32479;&#24433;&#21709;</P>"));
    }The results are
    abc def
    ????????????

  • Regular expressions to parse arithmetic expression

    Hello,
    I would like to parse arithmetic expressions like the following
    "5.2 + cos($PI/2) * -5"where valid expression entities are numbers, operations, variables and paranthesis. Until now I have figured out some regular expressions to match every type of entities that I need, and combine them into one big regex supplied to a pattern and matcher. I will paste some code now to see what I wrote:
    public class RegexTest {
        /** A regular expression matching numeric expressions (floating point numbers) */
        private static final String REGEX_NUMERIC = "(-?[0-9]+([0-9]*|[\\.]?[0-9]+))";
        /** A regular expression matching a valid variable name */
        private static final String REGEX_VARIABLE = "(\\$[a-zA-Z][a-zA-Z0-9]*)";
        /** A regular expression matching a valid operation string */
        public static final String REGEX_OPERATION = "(([a-zA-Z][a-zA-Z0-9]+)|([\\*\\/\\+\\-\\|\\?\\:\\@\\&\\^<>'`=%#]{1,2}))";
        /** A regular expression matching a valid paranthesis */
        private static final String REGEX_PARANTHESIS = "([\\(\\)])";
        public static void main(String[] args) {
            String s = "5.2 + cos($PI/2) * -5".replaceAll(" ", "");
            Pattern p = Pattern.compile(REGEX_OPERATION + "|" + REGEX_NUMERIC + "|" + REGEX_VARIABLE + "|" + REGEX_PARANTHESIS);
            Matcher m = p.matcher(s);
            while (m.find()) {
                System.out.println(m.group());
    }The output is
    5
    2
    +
    cos
    $PI
    2
    5There are a few problems:
    1. It splits "5.2" into "5" and "2" instead of keeping it together (so there might pe a problem with REGEX_NUMERIC although "5.2".matches(REGEX_NUMERIC) returns true)
    2. It interprets "... * -5" as the operation " *- " and the number "5" instead of " * " and "-5".
    Any solution to solve these 2 problems are greately appreciated. Thank you in advance.
    Radu Cosmin.

    cosminr wrote:
    So, I've written some concludent examples and the output after parsing (separated by " , " ):
    String e1 = "abs(-5) + -3";
    // output now: abs , ( , - , 5 , ) , + , - , 3 ,
    // should be:  abs , ( , -5 , ) , + , - , 3 , (Notice the -5)
    I presume that should also be "-3" instead of ["-", "3"].
    String e2 = "sqrt(abs($x=1 + -10))";
    // output now: sqrt , ( , abs , ( , $x , = , 1 , + , - , 10 , ) , ) ,
    // should be:  sqrt , ( , abs , ( , $x , = , 1 , + , -10 , ) , ) ,   (Notice the -10)
    String e3 = "$e * -1 + (2 - sqrt(4))";
    // output now: $e , * , - , 1 , + , ( , 2 , - , sqrt , ( , 4 , ) , ) ,
    // should be:  $e , * , -1 , + , ( , 2 , - , sqrt , ( , 4 , ) , ) ,
    String e4 = "sin($PI/4) - 3";
    // output now: sin , ( , $PI , / , 4 , ) , - , 3 , (This one is correct)
    String e5 = "sin($PI/4) - -3 - (-4)";
    // output now: sin , ( , $PI , / , 4 , ) , - , - , 3 , - , ( , - , 4 , ) ,
    // should be:  sin , ( , $PI , / , 4 , ) , - , -3 , - , ( , -4 , ) ,  (Notice -3 and -4)I hope they are relevant, If not I will supply some more.I made a small change to REGEX_NUMERIC and also put REGEX_NUMERIC at the start of the "complete pattern" when the Matcher is created:
    import java.util.regex.*;
    class Test {
        private static final String REGEX_NUMERIC = "(((?<=[-+*/(])|(?<=^))-)?\\d+(\\.\\d+)?";
        private static final String REGEX_VARIABLE = "\\$[a-zA-Z][a-zA-Z0-9]*";
        public static final String REGEX_OPERATION = "[a-zA-Z][a-zA-Z0-9]+|[-*/+|?:@&^<>'`=%#]";
        private static final String REGEX_PARANTHESIS = "[()]";
        public static void main(String[] args) {
            String[] tests = {
                "abs(-5) + -3",
                "sqrt(abs($x=1 + -10))",
                "$e * -1 + (2 - sqrt(4))",
                "sin($PI/4) - 3",
                "sin($PI/4) - -3 - (-4)",
                "-2-4" // minus sign at the start of the expression
            Pattern p = Pattern.compile(REGEX_NUMERIC + "|" + REGEX_OPERATION + "|" + REGEX_VARIABLE + "|" + REGEX_PARANTHESIS);
            for(String s: tests) {
                s = s.replaceAll("\\s", "");
                Matcher m = p.matcher(s);
                System.out.printf("%-21s-->", s);
                while (m.find()) {
                    System.out.printf("%6s", m.group());
                System.out.println();
    }Note that since Java's regex engine does not support "variable length look behinds", you will need to remove the white spaces from your expression, otherwise REGEX_NUMERIC will go wrong if a String looks like this:
    "1 - - 1"Good luck!

  • Regular expressions in 10g

    Can any body provide good Oracle 10g regular expression tutorial with example link ?

    Here below links from nice post entries from cd :
    Introduction to regular expressions ...
    Introduction to regular expressions ... continued.
    Nicolas.

  • Java – Regular Expressions – Finding any non digit byte in a multiple byte

    Hello,
    I’m new to JAVA and Regular Expressions; I’m trying to write a regular expression that will find any records that contain a non digit byte in a multiple byte field.
    I thought the following was the correct expression but it is only finding records that contain “all” non digit bytes.
    \D{1,}
    \D = Non Digit
    {1,} = at least 1 or more
    Below is my sample data. I would like the regular expression to find all of the records that are not all numeric. However when I use the regular expression \D{1,} it is only finding the 2 records that all bytes are non digits. (i.e. “ “ and “A “)
    “ 111229”
    “2 111229”
    “20091229”
    “200912c9”
    “201#1229”
    “20101229”
    “20110229”
    “20111*29”
    “20111029”
    “20111229”
    “20B11229”
    “A “
    “A0111229”
    Please note I have also tried \D{1,}+ and \D{1,}? And they also do not return my desired results
    Any assistance someone can provide would be greatly appreciated.

    You don't show the code you are using but I surmise you are using String.matches() which requires that the whole target must match the regular expression not just part of it. Instead you should create a Pattern and then a Matcher and use the Matcher.find() method. Check the Javadoc for Pattern and Matcher and look at the Java regex tutorial - http://docs.oracle.com/javase/tutorial/essential/regex/ .
    P.S. You can re-use the Pattern object - you don't have to create it every time you need one.
    P.P.S. Java regular expressions work with characters not bytes and characters are not not not bytes.

  • Regular expression in oracle for hypen

    Hi,
    I want to match a word "{color:#993300}83-ASG{color}" using regexp_like and i used '{color:#993300}^83-*{color}' pattern to match this word but this also matches words like "{color:#993300}8307-YUF{color}". could anyone please tell me what pattern should i use to match words like {color:#993300}83-ASG{color}.
    Also i need to know the similar pattern in oracle for the "{color:#993300}\b{}{color}" used in .net.
    Thanks in advance.
    Prasad

    Hi Prasad,
    Your regex could be as simple as '^83-'
    So, not much use for a regular expression:
    SQL> with test_data as (select '83-ASG' txt from dual union all
                       select '8307-YUF' from dual)
    -- end of test data
    select txt from test_data
    where txt like '83-%'
    TXT    
    83-ASG 
    1 row selected.Unless, you add some more value to it, perhaps like
    SQL> with test_data as (select '83-ASG' txt from dual union all
                       select '8307-YUF' from dual)
    -- end of test data
    select txt from test_data
    where regexp_like(txt, '^83-[[:upper:]]{3}$')
    TXT    
    83-ASG 
    1 row selected.Regards
    Peter

Maybe you are looking for