Splitting a string into each character.. 
Author Message
 Splitting a string into each character..

I have a reference number that I wish to split. The references look
like: 0201564F265

I want to split them into 0201 564 F265.

I have tried using "Split" in VBScript but I cannot work out how to
either stipulate the number of characters or to split into every
character (to later put them back together in the format above).

Does anyone have any bright ideas ?

The other alternative is to find a way of comparing only certain
characters of the ref with the database. But this again requires more
knowledge of SQL than I possess.

Matt.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 30 Mar 2002 03:00:00 GMT  
 Splitting a string into each character..

Are you asking for a VBScript answer (you posted in a JScript newsgroup)?

In VBScript,

strPart1 = Mid(myString,1,4)
strPart2 = Mid(myString,5,3)
strPart3 = Mid(myString,8,4)

In VBScript, the "start" position is the (1-based) ordinal position of the character.

In JScript,

strPart1 = String(myString).substr(0,4);
strPart2 = String(myString).substr(4,3);
strPart3 = String(myString).substr(7,4);

In JScript, the "start" position is the (0-based) offset of the character from the beginning of the string.

--
Michael Harris
  I have a reference number that I wish to split. The references look
  like: 0201564F265

  I want to split them into 0201 564 F265.

  I have tried using "Split" in VBScript but I cannot work out how to
  either stipulate the number of characters or to split into every
  character (to later put them back together in the format above).

  Does anyone have any bright ideas ?

  The other alternative is to find a way of comparing only certain
  characters of the ref with the database. But this again requires more
  knowledge of SQL than I possess.

  Matt.

  Sent via Deja.com http://www.deja.com/
  Before you buy.



Sat, 30 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Splitting a string into each character..

2. how to split a split string

3. Split string by regular expression (ie. date)

4. Splitting Strings

5. String Split

6. Newbie wants to split up strings

7. SPLIT A LONG STRING TO PUT IN A MULTILINE BOX

8. SPLIT A LONG STRING

9. Result of .split on a null string

10. Splitting a string into an array

11. Split string by regular expression (ie. date)

12. Splitting a String

 

 
Powered by phpBB® Forum Software