Extracting two strings from quotations in Java using regex?
- by user656710
Hi everyone,
I'm new to using patterns and looked everywhere on the internet for an explanation to this problem.
Say I have a string: String info = "Data I need to extract is 'here' and 'also here'";
How would I extract the words:
here
also here
without the single quotes using a pattern?
This is what I have so far...
Pattern p = Pattern.compile("(?<=\').*(?=\')");
But it returns ( here and 'also here ) minus the brackets, that is just for viewing. It skips over the second piece of data and goes straight to the last quote...
Thank you!