Connecting Tech Pros Worldwide Help | Site Map

How can I parse this string?

Newbie
 
Join Date: Apr 2008
Posts: 7
#1: Jun 28 '09
I have a few hundred records that look like this

mcnn 123030040506
mcas sa 123033
mscc 223449
mcnn sa 1000300300


What I need is the NUMBER part of the string, which, as you can see, the lenght is not always the same, BUT is always separated by an empty space from the rest and always on the right side.

Important: I need to use the query builder.

thanks in advance!!
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 2,994
#2: Jun 28 '09

re: How can I parse this string?


InStrRev() will locate the position of the last space in the string and you can then use Right() and Len() to parse out the characters beyond this final space.
Expand|Select|Wrap|Line Numbers
  1. NumberOnly: Right([FieldName],Len([FieldName])-InStrRev([FieldName]," ")+1)
Welcome to Bytes!

Linq ;0)>
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#3: Jun 29 '09

re: How can I parse this string?


Expand|Select|Wrap|Line Numbers
  1. NumberOnly:Mid([Some Field],InstrRev([Some Field], " ")+1)
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 2,994
#4: Jun 29 '09

re: How can I parse this string?


I always forget that Mid() doesn't require that third argument, and that if you omit it it returns everything until the end of the string.

Linq ;0)>
Newbie
 
Join Date: Apr 2008
Posts: 7
#5: Jun 30 '09

re: How can I parse this string?


great! thanks for the suggestions
Reply