Java Regex String Replace First replaceFirst(String str, String regex, String replacement, int patternFlag)

Here you can find the source of replaceFirst(String str, String regex, String replacement, int patternFlag)

Description

replace First

License

Apache License

Parameter

Parameter Description
patternFlag java.util.regex.Pattern

Declaration

public static String replaceFirst(String str, String regex, String replacement, int patternFlag) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Pattern;

public class Main {
    /**//ww w  .  ja v  a2  s.c  om
     * @param patternFlag {@link java.util.regex.Pattern}
     * 
     **/
    public static String replaceFirst(String str, String regex, String replacement, int patternFlag) {
        return Pattern.compile(regex, patternFlag).matcher(str).replaceFirst(replacement);
    }
}

Related

  1. replaceFirst(final String text, final Pattern regex, final String replacement)
  2. replaceFirst(final String text, final String regex, final String replacement)
  3. replaceFirst(String content, String regex, String replacement)
  4. replaceFirst(StringBuffer buf, StringBuffer aux, Pattern pattern, String replacement, int pos)
  5. replaceFirstIgnoreCase(String source, String search, String replace)
  6. replaceFirstOccurrence(String originalText, String oldString, String newString)
  7. replaceFirstStatement(String source, String regex, String statement)