7 Replies Latest reply: Jan 2, 2009 7:47 AM by 807589 RSS

    Regex issue

    807589
      I am trying to figure out regex to exclude particular word match .
      Like regex should match all other A-Z chars combination except the word "Default" .

      How do i do that ?
      Please suggest solution on this
        • 1. Re: Regex issue
          807589
          System.out.println("Not Default".matches("(?!Default).*"));
          System.out.println("Default".matches("(?!Default).*"));
          • 2. Re: Regex issue
            807589
            sabre150 wrote:
            System.out.println("Not Default".matches("(?!Default).*"));
            System.out.println("Default".matches("(?!Default).*"));
            Thanks sabre ! For u r reply .
            my need is slightly different .
            String str = "<tuv xml:lang=\"*ChangeMe*\" changedate=\"1900-01-01T12:00:00.000000\">";
                      str = str.replaceAll("xml:lang=\"*AnyThingExceptDefault*\"", "ChngedString");
            • 3. Re: Regex issue
              807589
              I can't tell what you are trying to do so I can't help. May be if you produced a before and after example it would make more sense.
              • 4. Re: Regex issue
                807589
                sabre150 wrote:
                I can't tell what you are trying to do so I can't help. May be if you produced a before and after example it would make more sense.
                String str = "<tuv xml:lang="ChangeMe" changedate="1900-01-01T12:00:00.000000">";
                
                if( xml:lang="ChangeMe"  Not having "Default" string ) {
                   then change that string otherwise let the string be as it is 
                }
                • 5. Re: Regex issue
                  807589
                  I still don't understand. Show a before and after example.
                  • 6. Re: Regex issue
                    807589
                    Case 1 :String before
                    String str = "<tuv xml:lang="Default" changedate="1900-01-01T12:00:00.000000">";
                    str = str.replaceAll("REGEX","newValue");
                    String After replace would be (No Change)
                    String str = "<tuv xml:lang="Default" changedate="1900-01-01T12:00:00.000000">";
                    Case 2 :String before
                    String str = "<tuv xml:lang="ChangeMe" changedate="1900-01-01T12:00:00.000000">";
                    str = str.replaceAll("REGEX","newValue");
                    String After replace would be (Changed String)
                    String str = "<tuv xml:lang="newValue" changedate="1900-01-01T12:00:00.000000">";
                    • 7. Re: Regex issue
                      807589
                      str = str.replaceAll("(xml:lang=\")(?!Default\")([^\"]*)\"","$1newValue\"");
                      {code}