import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(?<atributo>(?<pai>(?:[^=.\\n]+)\\.?){1,6})=(?<valor>(?:[^=\\n]+))$";
final String string = "php.environment.ini.session-name = sisicmbio\n"
+ "php.environment.ini.session-cookie_domain = icmbio.gov.br\n"
+ "php.environment.ini.session-auto_start = false\n"
+ "php.environment.ini.session-cookie_path = /\n"
+ "php.environment.ini.session-cookie_lifetime = 10800\n"
+ "php.environment.ini.session-cookie_httponly = true\n"
+ "php.environment.ini.session-use_only_cookie = true\n"
+ "php.environment.ini.session-gc_maxlifetime = 10800\n"
+ "php.environment.ini.session-cache_expire = 180\n\n"
+ ";; [php server mail]\n"
+ "php.mail.sender = smtp\n"
+ "php.mail.from = notifica@domain.gov.br ; conta default usada para enviar mensagens\n"
+ "php.mail.replyTo = reposta@domain.gov.br ; conta usada para reply\n"
+ "php.mail.wordWrap = 60\n"
+ "php.mail.priority = 3 ; 1: high, 3: normal, 5: low\n"
+ "php.mail.encoding = 8bit ; 8bit, 7bit, binary, base64, quoted-printable\n"
+ "php.mail.charset = utf-8\n"
+ "php.mail.contentType = text/html";
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL | Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html