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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to