Home » Java » Need to extract the values that follow a pattern in the string in Java

Need to extract the values that follow a pattern in the string in Java

Posted by: admin June 30, 2018 Leave a comment

Questions:

I have a string as below:

String a= "member;range=12001-*: CN=marimar,OU=Employees,OU=Cisco 
Users,DC=cisco,DC=com, CN=cadautel,OU=Employees,OU=Cisco 
Users,DC=cisco,DC=com CN=rajaki,OU=Employees,OU=Cisco 
Users,DC=cisco,DC=com";

I need to get the values of the CN attribute like ‘marimar’,’cadautel,’rajaki’ .

I have to use Java 7 to do that and hence I cannot use String.split() Can anybody help me out to come up with the logic.

Thanks!

Answers: