• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing Strings  RSS feed

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there! I am working on parsing some strings and cannot figure out how to do something. Say I have the following String:

FC5_P1595_PBUF0034_P1595_FC6

I know I can use the split method to get the following:
FC5
P1595
PBUF0034
P1595
FC6

However, is there some way of only returning the text in between the token like this:

P1595
PBUF0034
P1595

I could probably substring everything out, but I didn't know if there was something like the split method that I could use.

Thanks!
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jennifer,
this is a very low-tech solution.
when you use split and print you run the loop from 0 to strArray.length.
You can instead run from 1 to (strArray.length-1).
 
Jeff Rummings
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a regular expression.



There's a better way to represent a repeating group, but i can't recall how to do this off top of my head.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!