nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From PuspenduBanerjee <...@git.apache.org>
Subject [GitHub] nifi pull request: NIFI-924:Nifi-Camel Integration
Date Mon, 01 Feb 2016 23:28:29 GMT
Github user PuspenduBanerjee commented on the pull request:

    https://github.com/apache/nifi/pull/197#issuecomment-178252892
  
    @joewitt For Non-Uniform charset attached piece should work.
    
    ```java
    /**
         * @param rawBytes
         * @param patternToMatch
         * @return
         */
        private static boolean matchPattern(byte[] rawBytes , final String patternToMatch){
            out.println("Pattern= "+patternToMatch);
            final Pattern pattern = Pattern.compile(patternToMatch);
            final int patternByteLength=patternToMatch.getBytes().length;
            out.println("PatternByteLength= "+patternByteLength); 
            final int minSliceByteLength=2;
            final int sliceByteLength = patternByteLength > minSliceByteLength ? patternByteLength
: minSliceByteLength;
            int offset = 0;
            while (offset <= rawBytes.length) {
                String s=new String(Arrays.copyOfRange(rawBytes, offset>patternByteLength?
offset-(patternByteLength+1):0,
                                                       (offset + sliceByteLength)));
                out.println("Retrieved byte[]= "+s);
                if (pattern.matcher(s).find()) {
                    return true;
                }
                offset += sliceByteLength;
            };
            return false;
        }
    ```
    
    I tried with \:
    ```java
    matchPattern("I♥NY♥Y♥NABCDdkk;lskiepdmclod;die;'cnjywkl;sfdsXRSHSY♥♥Y".getBytes(),
"♥♥Y");
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message