wood burning stoves 2.0*
The moose likes Groovy and the fly likes Exploring Groovy features.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Exploring Groovy features.." Watch "Exploring Groovy features.." New topic
Author

Exploring Groovy features..

sree harsha.hn
Greenhorn

Joined: Jun 18, 2009
Posts: 7
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

"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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1621
    
  13

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.


No more Blub for me, thank you, Vicar.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exploring Groovy features..
 
Similar Threads
NewLine Problem in Regular Expressions
html:form
Logical Bug? - Method Recursion!
russian text(very urgent)
Problem with ObjectInputStream