Java extract string from text In this article, we will learn various ways to convert a string into a character array in Java with examples. Files class to read all the Jun 17, 2014 ยท there is something even simpler than using regex: String result = StringUtils. , start and end value as arguments. quote(pattern2); This will treat the pattern1 and pattern2 as literal text, and the text in between the patterns is captured in the first capturing group. file. ‘[‘ and ‘]’. We convert string to char array in Java mostly for string manipulation, iteration, or other processing of characters. [some text] [some number] [some more text] I want to extract the text in [some number] using the Java regex classes. getProperty("line. substring() method we just use the String.