Giter Site home page Giter Site logo

Comments (2)

prasanthkv avatar prasanthkv commented on July 20, 2024

This library design to optimize regex patterns to mask string file or format does't matter.
Here is an example of how to configure patten for plain text.

public class HeaderFieldPatternBuilder extends AbstractRegexPatternBuilder {
//https://regex101.com/r/yFABRL/7
private static final String TOTAL_PATTERN_TEMPLATE = "((?i)%s)=([^\\&\"]{1,10})*";
private static final String TOTAL_REPLACEMENT_TEMPLATE = "$1=******";
//https://regex101.com/r/yFABRL/7
private static final String PATTERN_TEMPLATE = "((?i)%s)=([^\\&\"]{1,%d})*";
private static final String REPLACEMENT_TEMPLATE = "$1=xxxx-$2";
/**
* Build pattern to match
*
* @param visibleCharacters as no of characters to be visible.
* @param fieldNames as list of field names
* @return match patternAbstractRegexPatternBuilderTest
*/
@Override
public String buildPattern(int visibleCharacters, String... fieldNames) {
String regexOr = super.buildFieldNamesForRegexOr(fieldNames);
return (visibleCharacters > 0) ? String.format(PATTERN_TEMPLATE, regexOr, visibleCharacters) : String.format(TOTAL_PATTERN_TEMPLATE, regexOr);
}
/**
* Build pattern to replace.
*
* @param visibleCharacters as no of characters to be visible.
* @param fieldNames as list of field names
* @return match pattern
*/
@Override
public String buildReplacement(int visibleCharacters, String... fieldNames) {
return visibleCharacters > 0 ? REPLACEMENT_TEMPLATE : TOTAL_REPLACEMENT_TEMPLATE;
}
}

from ejmask.

prasanthkv avatar prasanthkv commented on July 20, 2024

@SteadyStill if you have any specific use case in mind please elaborate with an example

from ejmask.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.