Different results using Matcher.replaceAll on a literal type of update

I expect the results for all of the following scenarios would have been the same:

public class {PatternMatcher

Public Shared Sub main (String [] args) {}

Model p;

Matcher m;

duplicates

p = Pattern.compile ("(.*)");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

unique

p = Pattern.compile ("(.+)");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

WTF

p = Pattern.compile ("(.*?)");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

duplicates

p = Pattern.compile ("(.*+)");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

unique

p = Pattern.compile ("^(.*)");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

duplicates

p = Pattern.compile ("(.*) $");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

unique

p = Pattern.compile ("^(.*) $");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

unique

p = Pattern.compile ("(.)) (. *).)");

m = p.matcher ("abc");

If (m.matches ()) System.out.println (p + ":" + m.replaceAll ("xyz"));

}

}

But the results vary depending on the type of update:

(. *): xyzxyz

(. +): xyz

(.*?) : xyzaxyzbxyzcxyz

(. * +): xyzxyz

^(.*): xyz

(. *) $: xyzxyz

^(.*) $: xyz

(. (.*).) : xyz

Because all models have a capturing group that covers everything, but the replacement string has no references of group, I expect that in any case the replacement string would simply be returned unchanged (so just "xyz").

I discovered a bug in the main library?  or am I misunderstood how it should work?

Now for a real answer.

(. *) will produce two matches "abc" and "" (the end of the string) because the * means we can have zero. Idk if this is a standard regex, but it is this that java is. So let's replace it with "xyz" and produce "xyzxyz".
(. +) only has a game and works as expected
(.*?) is lazy and weird and will be 4 groups to capture anything. To see, ' | ' which is a capture ' |. ' a | b | c | ». so we will produce "xyzaxyzbxyzcxyz".

(.*+) Idk what it should even do lol

so on, etc.

All of this has to do with the fact that regex. * seems to act funny.

Tags: Java

Similar Questions

  • using the same search terms on ebay, getting different results on firefox exploer

    using the same words to search on ebay for internet explorer, I get results more when I use ebay on FireFox > is cutting some of the results when using Firefox

    It is always possible that eBay is to differentiate between browsers and gives different results, based on previous visits.
    You can try to delete cookies in two browsers to see if it has an impact.

    "Clear the Cache":

    • Firefox/tools > Options > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Firefox/tools > Options > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".
  • Flatten channel gives different results on a RT system compared to a Windows system?

    When I flatten a structure moderately complex to a string in LabVIEW Windows, I get a slightly different result than when I do the same thing (interactive) Looking RT. LabVIEW to hexadecimal display produced channels, towards the tail end of the strings that I see:

    Windows: A 999, 0000. FB99 A 9999 9999 9999 9, 00
    RT: 9999 A000... FB99 9999 9999 99A 0 0000

    Shouldn't get the same value of the two systems?

    Your problem is the use of the extended data type.  I don't have a cRIO to do more thorough testing, but the only items that do not match are the two elements of smoothing.  The two values differ by about - 5.54976E - 18 (that is to say, not much - less, in fact, the value of epsilon machine).  If you use the context-sensitive help and hover on an EXT thread, you'll see a note indicating the precision varies by platform, so it must be provided.  Also documented A in aid, under the heading "digital, data types table.  Is there a reason why a double precision is not sufficient?

  • Why Express PSD gives a different result of amplitude as FFT PSD?

    Hello

    When I use the express VI of spectral measures to trace the power spectral density, I get a different result than when using the FFT PSD VI. The data are the same but the amplitudes are different in the PSD plot. Everyone comes through this?

    Thank you

    Donners,

    The PSD2 and graphic PSD2 are different because you are breastfeeding two extra points in the tables (t0, df). When graphic entry of data in the tables, they interpret not automatically information of t0 and df.  Actually they do not yet receive this information.  You must program the scales with nodes of property.  If you simply draw the order of magnitude, the spectra are very similar.

    ^ ^ ^ This confuses only the chart!

    The spectral forms differ slightly as the power spectrum of FFT and PSD.vi uses a default Hanning window.

    Lynn

  • Different results from the the DLL source code

    Hi all

    I'm new to this forum and also to labview so understandable...

    Then, I got a source project with many under vi of that graphic plots of excel files. I also got the exe after generation.

    The problem is, if I try to compile this project again, the exe gives me different results than what I already have. They should be the same, because I does no update in the source code.

    Can someone explain this behavior? I don't know anything about how it has been made because the guy who create this left the office... I need to make a few updates, but first of all, I have to build corectly.

    Thank you

    Have you compared the date of the exe file with the date of the source code? Are you absolutely sure that no changes have been made to the source code after the build? The construction specifications are part of the project. Unless you changed something there, builds should be the same.

    You have the source code control? Issues like this should not be a if you make and use wisely.

  • Why can I get two different results from the same coefficients?

    I get two different results of the evaluation of the polynomial function.

    For the first, I get the coefficients of a polynomial function to adapt.  I feed the coefficients of the function made the function Eval Poly and get the correct 12.8582 result when I evaluate 49940.

    For the second, I create constant array of values that have been returned by the polynomial Fit function (I typed in).  However, I get an incorrect result of - 120.7913 when I feed the constant table the function Eval Poly when I evauate 49940.

    How this can happen when I use the same values in table?

    A picture of what I explained is attached.

    Hi Altran,

    are you sure about using the 'same '?

    You compare them? Do you have (at least) set them to 17 digits display properties?

    Please attach a VI instead of an image...

  • "The eigenvalues and the vectors.vi" produce different results in BT 7.0 and 8.0

    I noticed that 'clean and vectors.vi values' product of different results when it is used in LV8.0 and LV7.0.

    The attached VI is saved in LV7.0.  The default values show the results by operating this VI in LV7.0.

    Using the same entries, try running this VI in 8.0 and you will see the results change.

    Someone has any ideas why this is happening?


  • Display different results with if statements

    Hello

    I'm doing a very simple logic but can't figure out how to do visually in LabView. Please take a look in the file. As you can see on the right, I have a group of 9 possibilities, each of them being true I want the COMPOUND NUMBER indicator to show a different result. I tried to use the structure of the case, but I could not the icon of the indicator in other sous-schemas. I also thought about putting the results in a table and choose the element whereby the possibilities.

    But I'm sure there is an easier way. Help, please.

    Thank you

    LD

    You put the indicator of terminal outside the structure of the case.  Then each case son its respective result in the tunnel leading out of the structure of the case to the indicator.

    (Alternative, but not recommended, use a local variable of the indicator in all other cases, if you use the terminal in one of the cases.)

  • When you try to find the IP address of my computer, I see two different results with two different numbers. Which is accurate?

    original title: a different output for ping - an IP address

    I am trying to determine the name of the computer to an IP address

    When I open a command prompt in a computer (Windows XP connected to our domain) and type ping - a [IP address], I get a result

    When I open a command prompt in another computer (Windows Server 2008 connected to the WORKING group) and type ping - a [IP address], I get a different result

    And there are other times when ping - [IP address] will display the name of the computer on a computer (usually the Windows Server 2008), but not the other

    I tried to google

    1. why this happens

    2. what result is correct

    Please specify.

    The order of DNS in Windows name resolution is as follows:

    1. Name of the local host (file Hosts Local generally in c:\windows\system32\drivers\etc\hosts)
    2. Cache Client DNS resolution
    3. DNS server
    4. Cache of NetBIOS names
    5. WINS server
    6. NetBIOS broadcasts
    7. File LMHosts (same location as the HOSTS file)

    The reason you get different results could be because machines could be on different subnets (different results for broadcast), using a different DNS server machines or are configured for different WINS servers, or the names are already cached because of prior activity.

    HTH,
    JW

  • A few keys return a different result example I press o and he returned .o

    My son has been on the computer (asus k53s) laptop. I don't know what he did, but now some of the traits keyboard return a different result, it feels almost like a kind of shortcut function. I restarted snd got the same result

    Here are the problems I found.
    o and. They all return two .o
    q returns a q and a tab
    m and refer my
    v and t both return a vt
    x starts the Help window
    I can't use my laptop properly right now that one of the letters is used in the passwd file, I use the keyboard to the mouse on screen.
    I need help asap thank you

    You can try the system restore to go back before the problem?

    How to repair the operating system and how to restore the configuration of the operating system to an earlier point in time in Windows Vista (or 7)
    http://support.Microsoft.com/kb/936212/#appliesTo

    I see that the OSK works for you, so perhaps the problem is a defective keyboard?  Have you tried to turn the laptop upside down and gently pat down to try to remove some of the bread crumbs between the keys (Lol).

    You can plug in another USB keyboard into the laptop and test with that?

  • ASCIISTR function that gives different results

    Hi Experts,

    I use the function ASCIISTR and it gives different results in SQLPLUS and TOAD

    SQLPLUS
    SQL> SELECT ASCIISTR('é') UC FROM DUAL
      2  ;
    
    UC
    -----
    \201A
    
    SQL> SELECT ASCIISTR('ú') UC FROM DUAL;
    
    UC
    -----
    \00A3
    TOAD
    SELECT ASCIISTR('ú') UC FROM DUAL
    
    \00FA
    
    SELECT ASCIISTR('é') UC FROM DUAL
    
    \00E9
    I know experts here will be reluctant to respond to questions about the TOAD, but I wanted to understand if I'm missing something. I checked the NLS_SESSION_PARAMETERS in SQLPLUS and TOAD, and they are the same. :-(does not understand this behavior

    Version of database Oracle Database * 10g Enterprise Edition Release 10.2.0.3.0 - 64 bit Production *.

    Thanks in advance!

    The default code for the command line page is 437, identical to TOAD, you want to get the code page 1252

    SQL> host chcp
    Active code page: 437
    
    SQL> SELECT ASCIISTR('é') UC FROM DUAL;
    
    UC
    _____
    \201A
    
    SQL> host chcp 1252
    Active code page: 1252
    
    SQL> SELECT ASCIISTR('é') UC FROM DUAL;
    
    UC
    _____
    \00E9
    
    SQL>
    
  • Different results of exactly the same query

    Hello

    I wrote a function to calculate the days between 2 dates. If I am running in SQL Developer or directly on the oracle server, I get the results I expected. However, if I run on a client by using ODBC, or PHP connection via the OCI8 extension, I get an incorrect result.

    The function takes 2 parameters: 1st and 2nd date and should output the number of non-working days (weekends and holidays) between 2 dates. The coding is not very pretty, but it does not work very well as I said since the client SQL Developer.

    Here is the code:
    create or replace
    FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE)
    --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays)
    --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013
    
    RETURN NUMBER IS
    BANK_HOLS NUMBER;
        ret NUMBER;
    BEGIN
        SELECT count(mydate) INTO ret FROM 
     (SELECT     TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate
                    FROM DUAL
               CONNECT BY LEVEL < =
                                TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss')
                              - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss')
                              + 1)
         WHERE TO_CHAR (mydate, 'DY') IN ('SAT', 'SUN');
         
         
         select count(mydate) into BANK_HOLS from (
         SELECT     TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate
                    FROM DUAL
               CONNECT BY LEVEL < =
                                TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss')
                              - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss')
                              + 1
         )
         WHERE TO_CHAR (mydate, 'DD-MM-YYYY') IN 
         ('03-01-2011', 
         '22-04-2011',
         '25-04-2011',
         '29-04-2011',
         '02-05-2011',
         '30-05-2011',
         '29-08-2011',
         '26-12-2011',
         '27-12-2011',
         '02-01-2012',
         '06-04-2012',
         '09-04-2012',
         '07-05-2012',
         '04-06-2012',
         '05-06-2012',
         '12-07-2012',
         '27-08-2012',
         '25-12-2012',
         '26-12-2012',
         '01-01-2013',
         '29-03-2013',
         '01-04-2013',
         '06-05-2013',
         '27-05-2013',
         '12-07-2013',
         '26-08-2013',
         '25-12-2013',
         '26-12-2013'
         );
         ret:= ret + BANK_HOLS;
         
        RETURN ret;
    end;
    The problem is only with certain dates. For example, if I use the date '17-SEP-2012' for the two input parameters, I'm waiting for a result draw. In the SQL Developer client, I get the expected result. However, using ODBC or PHP OCI8 (which I believe is using a direct connection to TNS in the DB), the result returned is '1', which is incorrect ("17-SEP-2012" has been a MONDAY ""). If I use the current date (20-SEP-2012), I get the expected (zero) result in both the SQL Developer client and ODBC/PHP client.

    I also tried to use variants of SYSDATE in place and place the date string, to see if I get different results (i.e. today is 20-SEP-2012, so I used SYSDATE-3 to 17-SEP-2012).

    To be clear, I call the function in a select statement: select (sysdate-3, sysdate-3) non_workdays of the double; or select non_workdays (TO_DATE('17-SEP-2012'), TO_DATE('17-SEP-2012')) of double;

    I have spent hours and hours of troubleshooting this, and it makes me crazy!

    I also checked the view V$ SQLAREA the Oracle DB to see what is actually passed to the ODBC client database engine. I was expecting the statement became corrupted somehow, that's why I get strange results, but this was not the case. The statement in the column SQL_FULLTEXT of V$ SQLAREA, showed exactly the statement I performed on the ODBC Client. I tried with the oracle instantclient and full client (10g).

    Can someone help save my sanity please? I am eternally grateful!

    Sorry for the massive post!

    Published by: user12199535 on 20-Sep-2012 12:20

    Your code is a mess. You convert DATE to DATE, e.g. TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss'). TO_DATE function first parameter is a string, while fromdate is the date. That's why Oracle implicitly converts fromdate to the string of default date format that is client dependent and therefore can produce different results on different customers boxes. In addition, your code is dependent on NLS. If the customer has other date language settings, for example German, Sun and SAT are false. And there is no need to separately calculate the weekends and holidays:

    create or replace
      FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE)
      --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays)
      --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013
        RETURN NUMBER
        IS
            BANK_HOLS NUMBER;
            ret NUMBER;
        BEGIN
            SELECT  count(mydate)
              INTO  ret
              FROM  (
                     SELECT  trunc(fromdate) + LEVEL - 1 mydate
                       FROM  DUAL
                       CONNECT BY LEVEL < = trunc(todate) - trunc(fromdate) + 1
                    )
              WHERE TO_CHAR(mydate,'DY','NLS_DATE_LANGUAGE = ENGLISH') IN ('SAT','SUN')
                 OR mydate IN (
                               DATE '2011-01-03',
                               DATE '2011-04-22',
                               DATE '2011-04-25',
                               DATE '2011-04-29',
                               DATE '2011-05-02',
                               DATE '2011-05-30',
                               DATE '2011-08-29',
                               DATE '2011-12-26',
                               DATE '2011-12-27',
                               DATE '2012-01-02',
                               DATE '2012-04-06',
                               DATE '2012-04-09',
                               DATE '2012-05-07',
                               DATE '2012-06-04',
                               DATE '2012-06-05',
                               DATE '2012-07-12',
                               DATE '2012-08-27',
                               DATE '2012-12-25',
                               DATE '2012-12-26',
                               DATE '2013-01-01',
                               DATE '2013-03-29',
                               DATE '2013-04-01',
                               DATE '2013-05-06',
                               DATE '2013-05-27',
                               DATE '2013-07-12',
                               DATE '2013-08-26',
                               DATE '2013-12-25',
                               DATE '2013-12-26'
                              );
            RETURN ret;
    end;
    /
    

    SY.
    P.S. I think that I converted your vacation to literals correctly, but still double check date.

  • whole different results

    Hello guys,.

    I use integer variables, function and block. But I do not understand that they behave differently. For example, although the input variable type is integer, but it behaves like the number, however, when I declare an integer in block (a1), it is rounded to the whole number, I mean, it works correctly.

    My question is what is the difference between these two integers? When I declare it in Notepad it working properly, however when I declare as a variable of office, it malfunctions?

    And also, another interesting thing is function around return type but it returns number, how it is possible?
    set serveroutput on;
    DECLARE
       a1 integer;
       FUNCTION plch_func1 (p1 INTEGER)
          RETURN INTEGER
       IS
       BEGIN
          dbms_output.put_line(p1);
          RETURN p1;
       END;
    BEGIN
       a1 := 0.54;
       DBMS_OUTPUT.PUT_LINE(a1);
       DBMS_OUTPUT.PUT_LINE(plch_func1(0.1));
    END;
    anonymous block completed
    1
    ,1
    ,1
    Thanks for your help.

    >
    That even means. In any case, it is incorrect. The reason is defined in the connection of the doc Boneist under OP in. It includes an example that is identical to the example of PAHO.
    >

    The reason for the result is described in the documentation. But the question I tried to answer one last by PO 'Why', why it is implemented this way?
    So I can't answer for doing so at all, just a little fishing in the waters of kamel, but what exactly is not correct?
    This is a setting IN, so that a reference is used. In the case of phenomenon couldn't happen, because an assignment is necessary before.
    Of course there is no implicit type conversion because the integer it is managed internally as number.

       create FUNCTION plch_func1 (p1 IN integer)
          RETURN INTEGER
       IS
       BEGIN
          RETURN p1;
       END;
    
    desc plch_func1
    
    Object Name     Argument     In Out     Datatype
    PLCH_FUNC1          OUT     NUMBER
          P1     IN     NUMBER
    

    Please give my a hint what part exactly was wrong, so that I can learn from you.

  • Two same queries but different results

    I'm working on the guarantee of data from data sources Vs target.
    Source and target databases are oracle. The source data are a remote database and navigate using DB_LINK.

    I am running similar queries against the data source and my schema but gets different results I check the number of folders and individual service Group DC account
    both are fit exactly, but for some reason any after the results of queries in different counts.

    a request flowing from the source table:
    Select
    b.Year,
    b.month,
    a.serv_grp,
    Count (distinct a.clnt) cnt
    Of
    Jay.srvrequest@bdm_link has,
    (select separate year, month, first_date_of_month, last_date_of_month)
    of dev.stage_3_time_dim
    where year = 2011 and
    b months between 3 and 7)
    where
    a.beg_dt < = b.last_date_of_month
    and a.end_dt > = b.first_date_of_month
    and a.serv_grp in ('1 ', '4', '5',' 6') and
    a.stat as 'A '.
    B.year group, b.month, a.serv_grp;


    target request flowing from the database:


    Select
    b.Year,
    b.month,
    a.service_group_cd,
    Count (distinct a.client_id) cnt
    Of
    Prod.stage_0_mg_serv_req has,
    (select separate year, month, first_date_of_month, last_date_of_month)
    of dev.stage_3_time_dim
    where year = 2011 and
    b months between 3 and 7)
    where
    a.begin_dt < = b.last_date_of_month
    and a.end_dt > = b.first_date_of_month
    and a.service_group_Cd in ('1 ', '4', '5',' 6') and
    a.status_cd as 'A '.
    B.year group, b.month, a.service_group_cd


    results out of data from the source as follows:
    Year month serv grp cnt
    2011 3 1 78653
    2011 3 4 4562
    2011 3 5 166
    2011 3 6 7533
    2011 4 1 78327
    2011 4 4 4540
    2011 4 5 167
    2011 4 6 7546
    2011 5 1 78612
    2011 5 4 4535
    2011 5 5 166
    2011 5 6 7544

    results off-target following data:
    Year month serv grp cnt
    2011 3 1 49350
    2011 3 4 1921
    2011 3 5 26
    2011 3 6 2259
    2011 4 1 47727
    2011 4 4 1834
    2011 4 5 27
    2011 4 6 2211
    2011 5 1 46675
    2011 5 4 1771
    2011 5 5 26
    2011 5 6 2116

    I don't know what wrong with queries
    any advice appreciated...

    Jay

    Maybe you get different results because the data are different.

    Also, why the first query uses a remote table, attached to a local table? Why not 100% remote data?

  • Connect Reporting different results to look at a pdf file

    Through a program of training and receipt, a team of users is necessary to read a pdf file, close it, and then recognize their agreement with the terms in the pdf file. In order to show completed in the curriculum, all courses must be completed. The pdf is set up as a course and need to show as completed. I see the results of different people who consult this pdf file. Some users show over some not taken when they say they have opened the pdf file and found that it. This is a 2 page document. Of the reasons why we would get such different results? To get a complete users should consult the two pages? Other suggestions?

    When I see this problem, it usually has to do with the conversion of the PDF file to allow the display of reports. Either re - download the PDF file and update the price or convert the document to HTML and use this current version. PDF conversion is random and frequent, but will allow some users to obtain a full and some show status does not matter how much the view the PDF.

Maybe you are looking for