D
D
DmitryPros2017-08-17 16:34:27
Java
DmitryPros, 2017-08-17 16:34:27

How to get an array of strings separated by a regular expression?

String str = "<title>title text</title>";
String regex = "(<title>)(.*)(</title>)";
String newString = /*---- Что здесь написать, чтобы получить title text? ----*/

How can you extract that line? I understand that for this you need to get an array and call the desired line from it at index [1]. How can I do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2017-08-17
@DmitryPros

String str = "text1 |это то, что я хочу извлечь| text";
String[] arr = str.split("|");
System.out.println(arr[1]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question