Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exploring Groovy features..

 
sree harsha.hn
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"mad skillz"

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.

Thanks for you understanding.

Mark
 
chris webster
Bartender
Posts: 2407
32
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic