Question
Consider the following Java code: import
java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexGroup { Â Â public static void main(String[] args) { Â Â Â Â String text = "Date: 2023-10-26, Time: 14:30"; Â Â Â Â Pattern pattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})"); Â Â Â Â Matcher matcher = pattern.matcher(text); Â Â Â Â if (matcher.find()) { Â Â Â Â Â Â System.out.println(matcher.group(0) + " | " + matcher.group(1)); Â Â Â Â } else { Â Â Â Â Â Â System.out.println("No match"); Â Â Â Â } Â Â } } What will be the output of this program?Solution
Correct Answer: A (matcher.group(0) returns the entire matched string. matcher.group(1) returns the content of the first capturing group, which is (\d{4}).)
What is the purpose of the Anand Marriage Act, which has been implemented in Jammu and Kashmir?
Who is the author of the book “The Sage with Two Horns: Unusual Tales from Mythology”?
SEBI has introduced the issue summary document for filing papers pertaining to IPO and for further issue of securities in XBRL format which  will be d...
Under which scheme, the sports stadium for the youth will be made in the state Rajasthan?
What does the Memorandum of Understanding (MoU) between AIIB and UNDP aim to strengthen?
Which of the following organisation released a study report, titled ‘Carbon Capture, Utilisation, and Storage (CCUS) Policy Framework and its Deployme...
What strategic advantage does the selling of Sovereign Gold Bonds (SGBs) by the Reserve Bank of India provide to the country's economy?
- IPS officer DK Kedia, who received the ‘CA in Public Service’ Award, belongs to which cadre?
Who among the following Mauryan kings turned to Buddhism and its tenet of nonviolence after the Kalinga war?
A-HELP programme has been launched in the State of Uttarakhand to strengthen livestock related activities in remote rural areas, keeping in mind their...