In this section you will learn how to compile a pattern with multiple flags like multiline, case insensitivity of the characters in the string etc. This section provides you an example for the implementation of the concept about how is it done? Following program has been used some APIs for compiling pattern with multiple flags i.e. explained ahead.
Program Result:
This program has mentioned string "Abc\ndef" as a input string and compiles the string "\n" which lies in the input string and replaced by the string "\t" after checking whether the pattern string either found or not in the input string. Here in the given program, the pattern string ("\n") is splitted from the input string.
Code Description:
Pattern.compile(patternStr, Pattern.MULTILINE |
Pattern.CASE_INSENSITIVE):
Above method compiles the string assigned with the String type
variable patternStr with multiple flags which are given follows:
Here is the code of the program:
import java.util.regex.*;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Compiling a Pattern with Multiple Flags
Post your Comment