Hi, I am brand new to java but I have a requirement where i am suppose to use Groovy.
So is there any good features that can address my requirement?
I have string like
str = "This is a sample text. Trying to explore groovy. In India, Bangalore, Harsha, N., with experts help";
In the above string am only interested in the Name of the person "Harsha" which will always be followed by letter N. and ","
(N stands for Name which will be after every name)
another example is ,
str = "This is a sample text. Trying to explore groovy. In India, Bangalore, Daniel O' Relly, N., with experts help";
Here I need to extract " Daniel O' Relly" which is followed by N. and "," to continue
So is there any features available in groovy that will do the job??
Please click the My Profile link above and change your display name to meet the JavaRanch Naming Policy of using your real first and real last names. Violators accounts will be disabled.
mad skillz wrote:
str = "This is a sample text. Trying to explore groovy. In India, Bangalore, Daniel O' Relly, N., with experts help";
Here I need to extract " Daniel O' Relly" which is followed by N. and "," to continue
So is there any features available in groovy that will do the job??
Well, I'm also pretty new to Java/Groovy etc, but it sounds like you should look at the Groovy documentation, especially the sections on string processing and regular expressions (regex). Groovy's regex support is based on Java's regex support, and regular expression syntax is widely used on different platforms, so you should be able to search around and find some tutorials or examples that will do what you want.
Like what Chris said, it's not hard to do it in Groovy. What you need to know is regular expression. And Groovy support for regular expression is awesome!
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog