This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Splitting a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting a string " Watch "Splitting a string " New topic
Author

Splitting a string

anoop kerala
Greenhorn

Joined: Mar 03, 2010
Posts: 10
Hi,
i want to split a string for example
1) @a.b=@c.d+@e.f;

one output i want is a,c,e which has got prefix '@'

second output i want is is b,d,f which has got prefix '.'

i prefer a solution with regex please..

thanks in advance
lenin
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20136
    
  30

Check out java.util.regex.Pattern. It has lots of information on regexes in Java. Especially check out what capturing groups do.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44581
    
  34
Rob Prime wrote:Check out java.util.regex.Pattern. It has lots of information on regexes . . .
There is lots more information in the tutorials, eg this one.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why do you want to use regexes? I'm not convinced that's the easiest solution to this problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting a string
 
It's not a secret anymore!