Intersection of 2 expressions

Hi,
I have a master-detail relation between 2 persistent classes. In java terminology, a master instance has a Collection of detail instances. I need to find master instances for which the collection contains detail 1 AND detail 2.
Example: Find all Employees having a Project with name="BigProject" AND a Project with budget="10000"
Note that the 2 conditions may be satisfied by 2 different projects. In other words, I don't mean "having a Project with (name="..." AND budget="...")
The following query pattern on the detail table returns the desired results :
SELECT DISTINCT <master id field>
FROM <detail table> t0
WHERE (t0.<field> = 'a value')
intersect
SELECT DISTINCT <master id field>
FROM <detail table> t0
WHERE (t0.<other field> = '<another value')
I don't know how to generate this, intersect is not in the Expression API.
Any ideas ?
JCG

Hi,
Here are some example expressions that I think will work:
ExpressionBuilder builder = new ExpressionBuilder(Employee.class);
Expression final =
builder.anyOf("projects").get("name").equal("BigProject").and(builder.anyOf
("projects".get("budget").equal("10000"));
This will return employees that have a Project named "BigProject" and a Project with budget "10000"
Another simliar expression:
Expression firstJoin = build.anyOf("projects");
Expression final = firstJoin.get("name").equal("BigProject").and(firstJoin.get("budget").equal("10000"));
This will return the employees who have a Project named "BigProject" with a budget of "10000". This is the situation you did not want.
Hope this helps.
Karen

Similar Messages

  • How to SQL intersect using Toplink expressions

    I try to do this SQL intersect
    SELECT part_k FROM ATTR_VALUE
    where commodity_n ='dab badge' and attribute_n='Badge Width' and attribute_value_x='10'
    INTERSECT
    SELECT part_k FROM ATTR_VALUE
    where commodity_n='dab badge' and attribute_n='Brand Logo' and attribute_value_x='Jaguar'
    using the following Toplink expressions:
    Expression e1 = builder.get("commodity").equal("dab badge")
    .and(builder.get("attribute").equal("Badge Width"))
    .and(builder.get("value").equal("10"));
    Expression e2 = builder.get("commodity").equal("dab badge")
    .and(builder.get("attribute").equal("Brand Logo"))
         .and(builder.get("value").equal("Jagua"));
    Expression myExpression = e1.and(e2);
    However, this would not give me the correct result.
    Any suggestions would be greatly appreicated.

    Right, TopLink doesn't have an Intersect operator. If it did, you might still get the same problem unless you are using a report query to return only the "part_k" value instead of an object since attribute_n cannot have a value of both 'Badge Width' and 'Brand Logo' at the same time.
    You can get the part_k values or the objects from the ATTR_VALUE
    table by using a report query for the second expression as a subquery to the IN clause. Something like
      ReportQuery subquery = new ReportQuery(yourclass.class);
      ExpressionBuilder subBuilder = subquery.getBuilder();
      Expression e2 = subBuilder.get("commodity").equal("dab badge").and(subBuilder.get("attribute").equal("Brand Logo")).and(subBuilder.get("value").equal("Jagua"));
      subquery.setSelectionCriteria(e2);
      subquery.addAttribute("partk");
      Expression myExpression = e1.and( builder.get("partk").in(subquery) );Regards,
    Chris

  • Error 00936 -Missing expression for INTERSECT function

    My sql is simple one:
    I have 2 tables customer and user module. I want to get customer id and count of
    users for that customer which has both module id 9 and 13 assigned to him.
    I am using an intersect to remove duplicates.
    select c.cust_id as "Customer Id",
      select count(user_id) from
         (select um.user_id from user_mod um
             um.user_cust_id = c.cust_id
              and um.umod_id = 9
           INTERSECT
          select um.user_id from user_mod um
          um.user_cust_id = c.cust_id
          and um.umod_id = 13
        ) as "Both Modules"
    from
    customer c
    where c.not_del = 0However I am getting a ora00936 at "select count(user_id)". Anyobdy know why and how to overcome it?

    The scalar subquery in your SELECT needs to be enclosed in parens like this:
    SELECT c.cust_id as "Customer Id", 
           (SELECT COUNT(user_id)
           FROM (SELECT um.user_id
                 FROM user_mod um
                 WHERE um.user_cust_id = c.cust_id and
                       um.umod_id = 9
                 INTERSECT
                 SELECT um.user_id
                 FROM user_mod um
                 WHERE um.user_cust_id = c.cust_id and
                       um.umod_id = 13)) as "Both Modules"
    FROM customer c
    WHERE c.not_del = 0.
    However, that will still not work since Oracle will not recognize c.cust_id in the nested part of the query. I would tend to write your query as something like:
    SELECT c.cust_id as "Customer Id"
    FROM customer c,
         (SELECT user_cust_id, COUNT(*) cnt
          FROM (SELECT user_cust_id
                FROM user_mod
                WHERE umod_id = 9
                INTERSECT
                SELECT user_cust_id
                FROM user_mod
                WHERE umod_id = 13)
          GROUP BY user_cust_id) b
    WHERE c.cust_id = b.user_cust_id(+) and
          c.not_del = 0HTH
    John

  • EXPRESSION= %VALUE% " Dimension intersections"

    Hi all
    I am on BPC7.5 SP04.
    We have script which is written in MS version. I would like to convert it to 7.5. Please find the code below let me know if you have any thoughts.
    1) In the Rec( Expression = %Value% <   " numeric value or some dimension combination " ---works in 7.5
    2) how to implement the boolean expression in 7.5 with a tuples
    *bold*This is the code in MS VERSION*bold*
    *XDIM_MEMBERSET CATEGORY=FORECAST
    //*XDIM_MEMBERSET COSTCENTER=%COSTCENTER_SET%
    *XDIM_MEMBERSET EMPCAT=SAL
    *XDIM_MEMBERSET EMPTYPE=%EXEMPT%,NOPOSITION
    *XDIM_MEMBERSET ENTITY=%ENTITY_SET%
    //*XDIM_MEMBERSET RPTCURRENCY=LC
    *XDIM_MEMBERSET H_ACCOUNT=TAXYTD,TAXFICAMAX,TAXFICAMIN
    *XDIM_MEMBERSET TIME=%MONTHS%,MTH.NA
    *WHEN SIGNEDDATA
           *IS > GET(H_ACCOUNT="TAXFICAMAX",EMPTYPE="NOPOSITION",TIME="MTH.NA")
             *REC(EXPRESSION=GET(H_ACCOUNT="TAXFICAMAX",EMPTYPE="NOPOSITION",TIME="MTH.NA"))
                *IS < GET(H_ACCOUNT="TAXFICAMIN",EMPTYPE="NOPOSITION",TIME="MTH.NA")
                     *REC(EXPRESSION=GET(H_ACCOUNT="TAXFICAMIN",EMPTYPE="NOPOSITION",TIME="MTH.NA"))
    *ENDWHEN
    *COMMIT
    *bold*This is the logic i wrote to convert into 7.5 - Please corrrect me if i am wrong *bold*
    *XDIM_MEMBERSET CATEGORY=FORECAST
    *XDIM_MEMBERSET COSTCENTER=100
    *XDIM_MEMBERSET EMPCAT=SAL
    *XDIM_MEMBERSET EMPTYPE=A1_GENMGR,NOPOSITION
    *XDIM_MEMBERSET ENTITY=CORP
    *XDIM_MEMBERSET RPTCURRENCY=LC
    *XDIM_MEMBERSET H_ACCOUNT=TAXYTD,TAXFICAMAX,TAXFICAMIN
    *XDIM_MEMBERSET TIME=2011.JAN,MTH.NA
    *WHEN EMPTYPE
          *IS A1_GENMGR
                     *REC(EXPRESSION=(%VALUE%<[H_ACCOUNT].[TAXFICAMAX],[EMPTYPE].[NOPOSITION],[TIME].[MTH.NA]),H_ACCOUNT="TAXFICAMAX",EMPTYPE="NOPOSITION",TIME="MTH.NA")
    *REC(EXPRESSION=(%VALUE%>([H_ACCOUNT].[TAXFICAMIN],[EMPTYPE].[NOPOSITION],[TIME].[MTH.NA])),H_ACCOUNT="TAXFICAMIN",EMPTYPE="NOPOSITION",TIME="MTH.NA")
    *ENDWHEN
    *COMMIT

    Thank you for the information Gersh and Sheldon.
    I the document was an intersting read. So here is the challange.
    Yes I am Developing the code in NW.
    so I tried to write the code using the Advance Programming Technique in the scriplogic Whitepaper.
    I tried it as below:
    bold<Code>
    *XDIM_MEMBERSET CATEGORY=FORECAST
    *XDIM_MEMBERSET COSTCENTER=%COSTCENTER_SET%
    *XDIM_MEMBERSET EMPCAT=%EMPCAT_SET%
    *XDIM_MEMBERSET EMPTYPE=<ALL>
    *XDIM_MEMBERSET ENTITY=%ENTITY_SET%
    *XDIM_MEMBERSET RPTCURRENCY=LC
    *XDIM_MEMBERSET H_ACCOUNT=TAXYTD,SALARYFICAMIN,SALARYFICAMAX
    *XDIM_MEMBERSET TIME=BAS(%TIME_SET%),MTH.NA
    IF TAXYTD < MIN THRESHOLD, SET TAXYTD CALCULATED TO MIN & IF TAXYTD > MAX, SET TAXYTD CALCULATED TO MAX
              *WHEN H_ACCOUNT
              *IS TAXYTD                                                              
    *REC(EXPRESSION=([H_ACCOUNT].[#TAXYTD])=([H_ACCOUNT].[TAXYTD])<([H_ACCOUNT].[SALARYFICAMIN],[TIME].[MTH.NA])?([H_ACCOUNT].[SALARYFICAMIN],[TIME].[MTH.NA]):(([H_ACCOUNT].[TAXYTD])>([H_ACCOUNT].[SALARYFICAMAX],[TIME].[MTH.NA])?([H_ACCOUNT].[SALARYFICAMAX],[TIME].[MTH.NA]):([H_ACCOUNT].[TAXYTD])),H_ACCOUNT="TAXYTD")
              *ENDWHEN
    *COMMIT
    When i run it in the ujkt tester it gives me a message as boldUJK_VALIDATION_EXCEPTION:Unknown Dimension Name in Keyword: "([H_ACCOUNT].[TAXYTD:
    I have doublechecked in the H_Account Dimension and I do see a memberset with the name TAXYTD.
    Not sure where I am going wrong.
    Tried breaking the code into two parts and see
    *XDIM_MEMBERSET CATEGORY=FORECAST
    //*XDIM_MEMBERSET COSTCENTER=100
    *XDIM_MEMBERSET EMPCAT=SAL
    //*XDIM_MEMBERSET EMPTYPE=A1_GENMGR,NOPOSITION
    *XDIM_MEMBERSET ENTITY=CORP
    *XDIM_MEMBERSET RPTCURRENCY=LC
    *XDIM_MEMBERSET H_ACCOUNT=TAXYTD,TAXFICAMAX,TAXFICAMIN
    *XDIM_MEMBERSET TIME=2011.JAN,MTH.NA
                *WHEN H_ACCOUNT
                     *IS TAXYTD
                          [H_ACCOUNT].[TAXYTD]=IIF([H_ACCOUNT].[TAXYTD] >([H_ACCOUNT].[TAXFICAMAX],[TIME].[MTH.NA],[EMPTYPE].[NOPOSITION]),([H_ACCOUNT].[TAXFICAMAX],[TIME].[MTH.NA],[EMPTYPE].[NOPOSITION]),[H_ACCOUNT].[TAXYTD])
                          //*REC(EXPRESSION=IIF([H_ACCOUNT].[TAXYTD] >([H_ACCOUNT].[TAXFICAMAX],[TIME].[MTH.NA],[EMPTYPE].[NOPOSITION]),([H_ACCOUNT].[TAXFICAMAX],[TIME].[MTH.NA],[EMPTYPE].[NOPOSITION]),[H_ACCOUNT].[TAXYTD]))
                *ENDWHEN
    *COMMIT
    *XDIM_MEMBERSET CATEGORY=FORECAST
    //*XDIM_MEMBERSET COSTCENTER=100
    *XDIM_MEMBERSET EMPCAT=SAL
    //*XDIM_MEMBERSET EMPTYPE=A1_GENMGR,NOPOSITION
    *XDIM_MEMBERSET ENTITY=CORP
    *XDIM_MEMBERSET RPTCURRENCY=LC
    *XDIM_MEMBERSET H_ACCOUNT=TAXYTD,TAXFICAMAX,TAXFICAMIN
    *XDIM_MEMBERSET TIME=2011.JAN,MTH.NA
                *WHEN H_ACCOUNT
                     *IS TAXYTD
                          [H_ACCOUNT].[TAXYTD]=IIF([H_ACCOUNT].[TAXYTD] < ([H_ACCOUNT].[TAXFICAMIN],[TIME].[MTH.NA],[EMPTYPE].[NOPOSITION]),([H_ACCOUNT].[TAXFICAMIN],[TIME].[MTH.NA],[EMPTYPE].[NOPOSITION]),[H_ACCOUNT].[TAXYTD])
                *ENDWHEN
    *COMMIT
    Still did not work
    Gives me the same error message as boldUJK_VALIDATION_EXCEPTION:Unknown Dimension Name in Keyword: "([H_ACCOUNT].[TAXYTD: Even though there is TAXYTD account in the H_Account Dimension
    Edited by: Sayapilla on Apr 26, 2011 10:59 AM

  • Need help in using a case statement in expression operator

    Hi All,
    I am using OWB version 10.2.0.1.0.
    My requirement is to add a new column called call _zone_key in expression operator and map it to the target table. I need to use the below expression for populating call_zone_key values
    Expression:
    case when (INGRP1.CHARGETYPE in ('O','F') or  INGRP1.TARIFF_GROUP in ('SMSINT','MMSINT')or ( INGRP1.CALL_TYPE = '002' and   INGRP1.TARIFF_GROUP  = 'MTV'))
    then
    (select call_zone_reltn_key from call_zone_reltn where
    call_zone_cd=substr(case
      when substr( INGRP1.B_SUBNO,1,2)='00'
      then
      substr( INGRP1.B_SUBNO,3)
      else substr( INGRP1.B_SUBNO,1)
      end,1,length(call_zone_cd))and rownum=1)
    else -1
    end
    All the columns needed for using the above expression is available in INGRP1 but still I am unable to deploy the mapping using above expression. Call_zone_reltn table is also imported to the module. I am getting below error
    Error:
    Warning
    ORA-06550: line 4980, column 2:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
       ( - + case mod new not null others <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> avg
       count current exists max min prior sql stddev sum variance
       execute forall merge time timestamp interval date
       <a string literal with character set specification>
       <a number> <a single-quoted SQL string> pipe
       <an alternatively-quoted string literal with character set specification>
       <an alternativ
    NEW_MOD_MAP_CELL_USAGE_FCT_PRE
    Create
    Warning
    ORA-06550: line 4989, column 43:
    PLS-00103: Encountered the symbol ")" when expecting one of the following:
       * & - + ; / at for mod remainder rem <an exponent (**)> and
       or group having intersect minus order start union where
       connect || multiset
    If i replace the expression with numbers such as 1 or 2, I am able to deploy the mapping.
    Kindly help in fixing this issue.
    Thanks,
    Kabilan

    You can't use the SELECT statement inside the expression, you need to join both tables before the expression. Use a Join operator with this JOIN condition:
    CALCULATED_CALL_ZONE_CD = call_zone_reltn.call_zone_cd ( + )
    Where Calculated_call_zone_cd proceed from a previous expression:
    CALCULATED_CALL_ZONE_CD = substr(case when substr( INGRP1.B_SUBNO,1,2)='00' then substr( INGRP1.B_SUBNO,3) else substr( INGRP1.B_SUBNO,1) end,1,length(call_zone_cd))
    And after joining both tables, you can use another expression to get the rownum, then another filter operator to keep only the rownum = 1, and now you can use your expression without the SELECT, using the call_zone_cd column from the outgroup in the joiner operator (you need to include that column in the filter operator to use it).
    Regards
    ANA GH

  • Pass intersection values when drilling through by clicking on a value in a matrix

    I have two SSRS reports. One is acting as a source report and the other as a target report.
    Both reports give information about "Customer Contact".
    My source report contains one matrix with the following attributes:
    Columns: Contact type (Email, Phone, Desk)
    Rows: Employee function (Administrative, Manager)
    Measure: Contact quantity
    The source report has two parameters on 'Contact type' and 'Employee function'
    My target report contains one matrix with the following attributes:
    Columns: Customer name
    Rows: Employee name
    Measure: Contact quantity
    The target report has two parameters on 'Contact type' and 'Employee function'
    I am using [Action] from the [Textbox property] of 'Contact Quantity' to go to my target report.
    What i want to achieve is the following:
    Lets say i select All for both parameters when running my source report.
    I get all the Contact types against all the Employee functions.
    Now the intersection between 'Email' and 'Manager' is 27.
    When i click on the value 27 in the matrix i want to go to my target report and pass trough Email and Manager so filtering can take place based on the intersection i clicked on in the source report.
    What it does now is just pass the full parameter value selected from the prompts in source report. I want to narrow it down.
    Any help? Thanks!

    Hello Qiuyun,
    Thank you very much for your reply.
    I have managed to get the drilltrough from source to target working correctly by passing the field value. I first got it to work on a small test data set and it works fine. However when i used this method on my production reports the performance became very
    bad. My first drilltrough took about 30 seconds instead of 2 seconds when i was passing the full parameter values. The next drilltrough gives back an out of memory error after quite some time (20 minutes +). 
    One important thing to mention is that these reports run on an SSAS cube. I made the following changes to the setup to get the pass field value method working.
    Initial setup: (Fast response)
    1. I start of by creating a new report.
    2. I select a the datasource (SSAS Cube) and i open the 'Query builder'.
    3. I then drag the attributes i need from the cube to the query.
    4. Afterwards i drag the attributes i want to use as parameters to the pane above the query and mark them as parameters. When finishing this step the parameters are automatically created in the design view (Report Data Pane) and within the data set of the
    report. When running the report the available values for the parameter are displayed automatically.
    5. Now i can run the report without having defined filters on the dataset. This setup performs very good but does not make it possible to pass trough field values.
    New setup: (Very slow response)
    1. I start of by creating a new report.
    2. I select a the datasource (SSAS Cube) and i open the 'Query builder'.
    3. I then drag the attributes i need from the cube to the query.
    4. I DON'T drag any attributes to the above pane (Dimension, Hierarchy, Operator, Filter Expression, Parameter) to be marked as parameters, i just finish after dragging to the query pane.
    5. Now i create my parameters manually in the design view (Report Data Pane).
    6. If i want to populate the parameters i do this by defining a separate dataset (query) per parameter to populate the drop down box. Otherwise i manually enter a string.
    7. I manually add the parameters to my dataset in the design view.
    8. Last i add filters which indicate what fields need to be filterd based on which parameter value.
    Any suggestions on how to get this working with acceptable performance?
    Thanks in advance for your help.
    (If you need screenshots to clarify the steps please let me know)
    Kind regards,
    Dennis

  • Regular expressions with boolean connectives (AND, OR, NOT) in Java?

    I'd like to use regular expression patterns that are made up of simple regex patterns connected via AND, OR, or NOT operators, in order to do some keyword-style pattern matching.
    A pattern could look like this:
    (.*Is there.*) && (.*library.*) && !((.*badword.*) || (^$))
    Is there any Java regex library that allows these operators?
    I know that in principle these operators should be available, since Regular languages are closed under union, intersection, and complement.

    AND is implicit,
    xy -- means x AND yThat's not what I need, though, since this is just
    concatenation of a regex.
    Thus, /xy/ would not match the string "a y a x",
    because y precedes x.So it has to contain both x and y, but they could be
    in any order?
    You can't do that easily or generally.
    "x.*y|y.*x" wouldll work here, but obviously
    it will get ugly factorially fast as you add more
    terms.You got that right: AND means the regex operands can appear in any order.
    That's why I'm looking for some regex library that does all this ugly work for me. Again, from a theoretical point of view, it IS possible to express the described semantics of AND with regular expressions, although they will get rather obfuscated.
    Unless somebody has done something similar in java (e.g., for C++, there's Ragel: http://www.cs.queensu.ca/~thurston/ragel/) , I will probably use some finite-state-machine libraries and compile the complex regex's into automata (which can be minimized using well-defined operations on FSMs).
    >
    You'd probably just be better off doing multiple
    calls to matches() or whatever. Yes, that's another possibility, do the boolean operators in Java itself.
    Of course, if you
    really are just looking for literals, then you can
    just use str.contains(a) && !str.contains(b) &&
    (str.contains(c) || str.contains(d)). You don't
    seem to need regex--at least not from your example.OK, bad example, I do have "real" regexp's in there :)

  • Match beginning of line with Regular Expression

    I'm confused about dreamweaver's treatment of the characters
    ^ and $ (beginning of line, end of line) in regex searches. It
    seems that these characters match the beginning of the file, not
    the beginning of the various lines in the file. I would expect it
    to work the other way around. A search like:
    (^.)
    should match every line in the file, so that a find/replace
    could be performed at the beginning of each line, like this:
    HELLO$1
    which would add 'HELLO' at the start of each line in the
    file.
    Instead, this action only matches the first character of the
    file, sticks 'HELLO' in front of it, and then quits (or moves on to
    the next file). The endline character $ behaves in a similar
    fashion, matching only the end of the file, not the end of each
    line.
    I've searched, and all the literature about regular
    expressions in dreamweaver seems to indicate that I'm expecting the
    correct behavior:
    www.adobe.com/devnet/dreamweaver/articles/regular_expressions_03.html
    quote:
    ^ Beginning of input or line ^T matches "T" in "This good
    earth" but not in "Uncle Tom's Cabin"
    $ End of input or line h$ matches "h" in "teach" but not in
    "teacher"
    Thanks for any insight, folks.

    Hi Winston,
    I am still digesting the material from the regular expression book and will take sometime to become proficient with it.
    It seems that using groupCount() to eliminate the unwanted text does not work in this case, since all the lines returned the same value. Ie 3 posted earlier. This may be because the patterns are complex and only a few were grouped together. Otherwise, could you provide an example using the string posted as opposed to a hyperthetic one. In the meantime, at least one solution have been found by defining an additional special pattern “\\A[^%].*\\Z”, before combining / intersecting both existing and the new special pattern to get the best of both world. Another approach that should also work is to evaluate the size of String.split() and only accept those lines with a minimum number of tokens.
    Anyhow, I have come a crossed another minor stumbling block in the mean time with the following line, where some hidden characters is preventing the existing pattern from reading it:
    o;?Mervan Bay 40 Boyde St 7 br t $250,000 X West Park AE
    Below is the existing regular expression that works for other lines with the same pattern but not for special hidden characters such as “o;?”:
    \\A([A-Z][a-z]*){1,2} [0-9]{0,4}/?[0-9]{0,4}-?[0-9]{0,4} ([A-Z][a-z]*){1,2} St|Rd|Av|Sq|Cl|Pl|Cr|Gr|Dr|Hwy|Pde|Wy|La [0-9] br [h|u|t] \\$\\d+,\\d+|\\$\\d*\\,\\d+,\\d+ ([A-Z][a-z]*){1,}\\ZIs it possible to come up with a regular expression to ignore them so that this line could be picked up? Would also like to know whether I could combine both the special pattern “\\A[^%].*\\Z” with existing one as opposed to using 2 separate patterns altogether?
    Many thanks,
    Jack

  • How many airport expresses would I need for a 3000 square foot apartment with minimal walls?

    The apartment is open-air style with minimal walls. I have two airport expresses currently and am wondering if this will be enough to cover the entire apartment? Any help is much appreciated. Thanks!

    You'll get about 50ft @ (-6db), you'll get about 100ft @ (-12db), both of these are useable figures, beyond a 100ft it will be patchy
    This assumes your AE is in free space, which it won't be as you need to plug into something, the more intersections (wall/ceilng wall/floor) the greater the chance of multipath rejection.
    3000sq ft relatively empty of dividers is a good space, but I would use 2

  • Need advice on negating a whole string line with regular expression

    Hi All,
    I am not able to ignore / get rid of the following line even though my Java 6 (Windows XP) String Pattern matching has not taken cater for it:
    *% Cleared: 61%*
    Below is the existing Java String Pattern matching in the simple program:
    Pattern pattern = Pattern.compile("(^.*[A-Z][a-z]*){1,2} \\d{0,4}/?\\d{0,4} ([A-Z][a-z]*){1,2} St|Rd|Av|Sq|Cl|Pl|Cr|Gr|Dr|Hwy|Pde|Wy|La \\d br [h|u|t] \\$\\d+,\\d+|\\$\\d*\\,\\d+,\\d+ ([A-Z][a-z]*){1,}.*$");This pattern is working for valid strings.
    The following pattern has included "^(?!.*\.\.).*$" into the existing one but had no luck still:
    Pattern pattern = Pattern.compile("^(?!.*\.\.).*$|((^.*[A-Z][a-z]*){1,2} \\d{0,4}/?\\d{0,4} ([A-Z][a-z]*){1,2} St|Rd|Av|Sq|Cl|Pl|Cr|Gr|Dr|Hwy|Pde|Wy|La \\d br [h|u|t] \\$\\d+,\\d+|\\$\\d*\\,\\d+,\\d+ ([A-Z][a-z]*){1,}.*$)");This picked up other rubbish including "*% Cleared: 61%*".
    I am looking for a single regular expression that applies to the whole line.
    I am quite new to regular expression but has read through Regular Expressions Cookbook (Oreilly - 2009) and is still not familiar with advance functions such as lookahead / lookbehind...
    Your assistance would be appreciated.
    Thanks,
    Jack

    Hi Winston,
    I am still digesting the material from the regular expression book and will take sometime to become proficient with it.
    It seems that using groupCount() to eliminate the unwanted text does not work in this case, since all the lines returned the same value. Ie 3 posted earlier. This may be because the patterns are complex and only a few were grouped together. Otherwise, could you provide an example using the string posted as opposed to a hyperthetic one. In the meantime, at least one solution have been found by defining an additional special pattern “\\A[^%].*\\Z”, before combining / intersecting both existing and the new special pattern to get the best of both world. Another approach that should also work is to evaluate the size of String.split() and only accept those lines with a minimum number of tokens.
    Anyhow, I have come a crossed another minor stumbling block in the mean time with the following line, where some hidden characters is preventing the existing pattern from reading it:
    o;?Mervan Bay 40 Boyde St 7 br t $250,000 X West Park AE
    Below is the existing regular expression that works for other lines with the same pattern but not for special hidden characters such as “o;?”:
    \\A([A-Z][a-z]*){1,2} [0-9]{0,4}/?[0-9]{0,4}-?[0-9]{0,4} ([A-Z][a-z]*){1,2} St|Rd|Av|Sq|Cl|Pl|Cr|Gr|Dr|Hwy|Pde|Wy|La [0-9] br [h|u|t] \\$\\d+,\\d+|\\$\\d*\\,\\d+,\\d+ ([A-Z][a-z]*){1,}\\ZIs it possible to come up with a regular expression to ignore them so that this line could be picked up? Would also like to know whether I could combine both the special pattern “\\A[^%].*\\Z” with existing one as opposed to using 2 separate patterns altogether?
    Many thanks,
    Jack

  • Regular expression for Period

    i want to write a regular expression which would allow any printable ascii but not period (.). how would this expression look like...anyone ??

    [\p{Print}&&[^.]] That's the intersection
    of the sets "all printable ASCII characters" and
    "everything but the period".:-) Once more showing my lack of knowledge!

  • Regular Expression Map

    Hi,
    I need some kind of a "RegExpMap" - a map that has the capability
    to bind value objects to a pattern (a regular expression) and to retreive that
    objects back by giving a sample that matches the pattern.
    void put(pattern, Object)
    Object get(sample)so that
    map.put("foo(.*)", o);
    assertTrue(map.get("foobar") == o);Does anyone of you know if there's such an implementation (freely) available?
    Thanks for your help in advance!
    Frank

    Regular expressions are normally computed by first converting the expression to a state machine (of one kind or another, depending on the type of regexp you are using). These state
    machines are then run on your string (character at a time). Now if you can create a state
    machine for each expression then you can potentially merge this set of state machines into a single new one.
    For example the union of two state machines provides a state machine that can match strings that either of the origininal SM's could. The intersection of two state manchines produces a
    state machine that can match string that both of the original SM's would have matched. The
    concatenation of two SM's will allow the a string composed of something that matches the first
    SM and something that matches the second SM to match etc.
    The lib asif pointed out does not do exactly what the OP wants but does provide a lot of the
    functionality that may be necessary to produce thier own combination method.
    Whether it is even possible (or if it would be more efficient then a linear search over all
    regexps) I don't know. Interesting though.
    matfud

  • Handling Regular expression ambiguitie s

    Hi All,
    I am attemting to make my own regular expression class. (Just for fun) :)
    I have successfully converted the regular expression into a DFA ( deterministic finite automaton ). However, as i have noticed, there is still ambiguity in transition when it comes to certain classes of regular expressions such as a+[^0-9]+w. this means one or more a's followed by one or more symbols that are NOT numbers, followed by a w. Now if we have a string "aaaw", the first a is matched quite nicely, but should the second 'a' be treated as an a that is to be matched with "a+" or "[^0-9]" ??
    Is there any algorithm that resloves such an ambiguity?
    Any help would be much appreciated. I am stuck with this issue and don't seem to have any leads at all :)

    Hi All,
    My problem is now solved. I have refined the suggestions to come up with the following algorithm ( excuse the errors, and ineffeciencies, if any )
    push all DFA states into a queue
    while !(dfaStateQueue.empty())
           currentDFAState = dfaStateQueue.pop()
           push all transitions of currentDFAState to transitionQueue.
           store all transitions into transitionArray.
            while ( !transitionQueue.empty() )
                   compareWithTransition = transitionQueue.pop();
                   for(i = 1 to length(transitionArray) )
                          compareWithTransition = transitionArray;
    Set intersec = set_intersection(compareWithTransition.getChars, compareToTransition.getChars);
    if( !intersect.empty() )
    //characters in compareWith but not in compareTo
    Set minus1 = set_difference(compareWithTransition, compareToTransition)
    //characters in compareTo but not in compareWith.
    Set minus2 = set_difference(compareToTransition, compareWithTransition)
    //compareWithTransition is subset of compareToTransition
    if(minus1.empty())
    replace characters of compareTo with characters in set minus2
    replace characters of a closure transition of compareTo
    with characters in set minus2
    compareWithTransition.nextDfa.addAllTransitions
    (compareToTransition.nextDfa.getTransitions())
    continue
    //compareToTransition is subset of compareWithTransition
    else if(minus2.empty())
    replace characters of compareWithTransition with characters in set minus1
    replace characters of a closure transition of compareWithTransition
    with characters in set minus2
    compareToTransition.nextDfa.addAllTransitions
    (compareWithTransition.nextDfa.getTransitions())
    continue;
    end if
    create new DFA state D;
    currentDFAState.addTransition(intersect, D);
    push D onto queue.
    D.addAllTransitions(compareWithTransition.nextDfa.getTransitions());
    D.addAllTransitions(compareToTransition.nextDfa.getTransitions());
    replace characters of compareWithTransition with characters in set minus1
    replace characters of compareToTransition with characters in set minus2
    end if
    end for
    end while
    end while
    I hope this helps everyone at large. Now there is no need for backtracking at all and DFAs are now truly "DFAs" :)
    I dont know if other tools employ this technique or not. Please ignore the glaring ineffeciencies. I have give the algorithm the way i coded it ( Never considered myself as effecient programmer in the first place) HAHAHA
    Chears,
    AUTOMATON                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why is Flash's Rectangle.intersection() slow?

    For some reason I can't fathom, I have long been able to get faster intersection tests for my own version of the Rectangle object. This is silly. Why should my code be any faster than the Flash player team's code - who have had 10 iterations of the Flash player to get it right?
    example:
    package {
         import flash.display.Sprite;
         import flash.events.Event;
         import flash.geom.Rectangle;
         import flash.utils.getTimer;
          * @author Aaron Steed, robotacid.com
         public class Main extends Sprite {
              public function Main():void {
                   if (stage) init();
                   else addEventListener(Event.ADDED_TO_STAGE, init);
              private function init(e:Event = null):void {
                   removeEventListener(Event.ADDED_TO_STAGE, init);
                   // entry point
                   var t:int, i:int;
                   var flashRect:Rectangle = new Rectangle();
                   var myRect:Rect = new Rect();
                   t = getTimer();
                   for(i = 0; i < 1000000; i++){
                        flashRect.intersects(flashRect);
                   trace(getTimer() - t);
                   t = getTimer();
                   for(i = 0; i < 1000000; i++){
                        myRect.intersects(myRect);
                   trace(getTimer() - t);
    class Rect{
         public var x:Number;
         public var y:Number;
         public var width:Number;
         public var height:Number;
         public function Rect(x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0){
              this.x = x;
              this.y = y;
              this.width = width;
              this.height = height;
         /* Do two Rects intersect? */
         public function intersects(b:Rect):Boolean{
              return !(this.x > b.x + (b.width - 1) || this.x + (this.width - 1) < b.x || this.y > b.y + (b.height - 1) || this.y + (this.height - 1) < b.y);
    Hell, even if I write a separate method and use
    return !(this.x > b.x + (b.width - 1) || this.x + (this.width - 1) < b.x || this.y > b.y + (b.height - 1) || this.y + (this.height - 1) < b.y);
    with a flash Rectangle it's still faster than using crappy old Rectangle.intersects()
    Why?
    Is there anyone at Adobe that could fix this, as I'm a bit fed up of up of having to write my own versions of Flash's geometry objects.

    Hi, I tried running a benchmark to test the speed, and accuracy of your intersects(), and I discovered that yours is not only 2x faster on my computer, it is also more accurate/robust than Flash's Rectangle.intersects()!
    Below is my benchmarking code, just copy into the first frame of a new Flash document and run.
    I have no idea why your suggestion (http://bugs.adobe.com/jira/browse/ASL-65) is marked resolved, when it is clearly not,
    but I have filed/cloned a bug report (http://bugs.adobe.com/jira/browse/FP-5350) regarding the issue, and also listing your version of intersects() as a workaround.
    Thanks, and cheerio XD.
    import flash.geom.Rectangle;
    import flash.utils.getTimer;
    import flash.text.TextField;
    function normal(i1:int, i2:int):int {
        var totalTime:int = 0;
        for (var i:int=0; i<i1; i++) {
            var rect1:Rectangle = new Rectangle(Math.random()*200-100, Math.random()*200-100, Math.random()*200-100, Math.random()*200-100);
            var rect2:Rectangle = new Rectangle(Math.random()*200-100, Math.random()*200-100, Math.random()*200-100, Math.random()*200-100);
            var startTime:int = getTimer();
            for (var j:int=0; j<i2; j++) {
                rect1.intersects(rect2);
            totalTime += getTimer() - startTime;
        return totalTime;
    function custom(i1:int, i2:int):int {
        var totalTime:int = 0;
        for (var i:int=0; i<i1; i++) {
            var rect1:Rectangle = new Rectangle(Math.random()*200-100, Math.random()*200-100, Math.random()*200-100, Math.random()*200-100);
            var rect2:Rectangle = new Rectangle(Math.random()*200-100, Math.random()*200-100, Math.random()*200-100, Math.random()*200-100);
            var startTime:int = getTimer();
            for (var j:int=0; j<i2; j++) {
                intersects(rect1, rect2);
            totalTime += getTimer() - startTime;
        return totalTime;
    function intersects(a:Rectangle, b:Rectangle):Boolean {
        return !(a.x > b.x + (b.width - 1) || a.x + (a.width - 1) < b.x || a.y > b.y + (b.height - 1) || a.y + (a.height - 1) < b.y);
    function test(i1:int, i2:int):int {
        var totalTime:int = 0;
        for (var i:int=0; i<i1; i++) {
            var rect1:Rectangle = new Rectangle(Math.random()*200-100, Math.random()*200-100, Math.random()*200-100, Math.random()*200-100);
            var rect2:Rectangle = new Rectangle(Math.random()*200-100, Math.random()*200-100, Math.random()*200-100, Math.random()*200-100);
            var startTime:int = getTimer();
            for (var j:int=0; j<i2; j++) {
                try {
                    assert(intersects(rect1, rect2) == rect1.intersects(rect2));
                catch (e:Error) {
                    this.x = 100;
                    this.y = 100;
                    graphics.clear();
                    graphics.beginFill(0xff0000, 0.5);
                    graphics.drawRect(rect1.x,rect1.y,rect1.width,rect1.height);
                    graphics.endFill();
                    graphics.beginFill(0x00ff00, 0.5);
                    graphics.drawRect(rect2.x,rect2.y,rect2.width,rect2.height);
                    graphics.endFill();
                    trace(rect1, rect2, intersects(rect1, rect2), rect1.intersects(rect2));
                    throw new Error("Assertion failed!");
            totalTime += getTimer() - startTime;
        return totalTime;
    function assert(expression:Boolean):void {
        if (!expression) throw new Error("Assertion failed!");
    trace('Rectangle.intersects():', normal(1000, 1000));
    trace('custom intersects():', custom(1000, 1000));
    trace('test accuracy of custom intersects():', test(1000, 1000));

  • Lines intersecting that has a point in a polygon

    Hi Spatial Community,
    I would like to get your expertise in trying to see how can we get this done via Oracle Spatial.
    The requirement is to write a file
    - passed intersection of line that have a point within a polygon
    - failed intersections( doe snot have any line intersecting) that have a point within a polygon
    Any clues is much appreciated.
    Edited by: CrackerJack on Feb 25, 2013 12:46 PM

    Comments before have been pretty much on the money perhaps I might just add
    Using the cola_markets example from the manual...
    -- Return the topological intersection of two geometries.
    SELECT SDO_GEOM.SDO_INTERSECTION(c_a.shape, c_c.shape, 0.005)
    FROM cola_markets c_a, cola_markets c_c
    WHERE c_a.name = 'cola_a' AND c_c.name = 'cola_c';
    SDO_GEOM.SDO_INTERSECTION(C_A.SHAPE,C_C.SHAPE,0.005)(SDO_GTYPE, SDO_SRID, SDO_PO
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
    AY(4, 5, 3, 3, 5, 3, 5, 5, 4, 5))
    So that finds the ones that DO interact
    To do the DISJOINT: The boundaries and interiors do not intersect.
    Use SDO_ANYINTERACT as someone else also suggested
    The expression SDO_ANYINTERACT(geometry1,geometry2) = 'TRUE' evaluates to TRUE for object pairs that have the ANYINTERACT topological relationship, and FALSE otherwise.
    The False version which your will need
    SQL> SELECT c.mkt_id, c.name
    FROM cola_markets c
    WHERE SDO_ANYINTERACT(c.shape,
    SDO_GEOMETRY(2003, NULL, NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,3),
    SDO_ORDINATE_ARRAY(4,6, 8,8))
    ) != 'TRUE';
    2 3 4 5 6 7
    MKT_ID NAME
    3 cola_c
    5 cola_d5
    And for completeness the reverse
    SQL> SELECT c.mkt_id, c.name
    FROM cola_markets c
    WHERE SDO_ANYINTERACT(c.shape,
    SDO_GEOMETRY(2003, NULL, NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,3),
    SDO_ORDINATE_ARRAY(4,6, 8,8))
    ) = 'TRUE';
    2 3 4 5 6 7
    MKT_ID NAME
    1 cola_a
    2 cola_b
    4 cola_d
    Cheers
    Rich

Maybe you are looking for