Jump to content

Help spliting a string


Dryden
 Share

Recommended Posts

Hi guys. I need some help.

I'm tring to read the fields of a file the problem is that this kind of files are all messed up.

I already have the file contents in a string and it goes something like this:

EX:

bla bla bla bla bla bla +bla bla bla ++bla bla bla bla ++++bla bla bla ++bla bla bla ++++bla bla bla bla ++bla bla ++++++bla bla bla ++++bla bla bla

so I wanted to split the variable whenever I encounter 4 plus signs (++++), and show each one of the variables.

thx in advance.

"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Link to comment
Share on other sites

I already tried StringSplit, the problem is that I can't make it work with "++++" as a delimiter, cos it acts the same either I put "+" or "++" or "+++", and I want it only to split in "++++"

and btw I don't know how many ++++ there will be, so I can't define the array. isn't there a way to count them before creating the array?

Edited by Dryden

"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett.

Link to comment
Share on other sites

StringSplit ( "string", "delimiters" [, flag ] )

[optional] If flag is 0 (the default), then each character in the delimiter string will mark where to split the string. If flag is 1, then the entire delimiter string is needed to mark the split.

flag needs to be 1

Link to comment
Share on other sites

ok... in your example you show "+++++" (5 plus') but want to detect "++++" (4 plus'). So should the "+++++" (5 plus') be detected as a "++++" (4 plus')? If so, would you want the string after the last plus or only after the fourth (meaning the string would start with "+")?

This may be a job for StringRegExp()

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...