Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting a string  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 21204
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out java.util.regex.Pattern. It has lots of information on regexes in Java. Especially check out what capturing groups do.
 
Marshal
Posts: 57276
175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to use regexes? I'm not convinced that's the easiest solution to this problem.
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!