Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sivarajs
Specialist II
Specialist II

splitting a string

Hi,

I want to split a string and need to take first letter of substring to make a new field

e.g:   ABC TECH LTD  as ATL

How can i acheive this?

Regards,

Sivaraj

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Probably not, but you can track the Text line and the subfield order like this:

TEXTS:

Load

     recno() as TextID,

     rowno() as PartID,    

     left(subfield(F1,' '),1) as Parts;

Load * inline [

F1

ABC TECH LTD

Hello world

Beta Alpha

];

Load

     TextID,

     concat(Parts,'',PartID) as Done

resident TEXTS group by TextID;

View solution in original post

10 Replies
Not applicable

this is one string (one field)

or

three fields?

Anonymous
Not applicable

You Can try something like this.. considering this is a single field value..

Left(SubField(Name, ' ', 1), 1) = This will get you the result A

Left(SubField(Name, ' ', 2), 1) = This will get you the result T

Left(SubField(Name, ' ', 3), 1) = This will get you the result L

Left(SubField(Name, ' ', 1), 1) & Left(SubField(Name, ' ', 2), 1) & Left(SubField(Name, ' ', 3), 1) = This will give you ATL

hope that helps..

Anonymous
Not applicable

This example script should help you out:

Load

          concat(Parts) as Done;

Load

          left(subfield(F1,' '),1) as Parts;

Load * inline [

F1

ABC TECH LTD

];

Miguel_Angel_Baeyens

Hi,

Another option, not very orthodox but useful in case the field has not fixed number of elements (not always 3) would be the following:

=Concat(Left(SubField('ABC TECH LTD', ' ', ValueLoop(1, SubStringCount('ABC TECH LTD', ' ') +1, 1)), 1), '', ValueLoop(1, SubStringCount('ABC TECH LTD', ' ') +1, 1))

Hope that helps.

Miguel

gandalfgray
Specialist II
Specialist II

Johannes example concatenates the Parts in random order,

and if there is more than one record in the inline table,

the initials from the different records get mixed.

So:

Load

     concat(Parts) as Done;

Load

     left(subfield(F1,' '),1) as Parts;

Load * inline [

F1

ABC TECH LTD

Hello world

];

gives me a Done: AHLTw

I don't think that's what you want.

swuehl
MVP
MVP

Probably not, but you can track the Text line and the subfield order like this:

TEXTS:

Load

     recno() as TextID,

     rowno() as PartID,    

     left(subfield(F1,' '),1) as Parts;

Load * inline [

F1

ABC TECH LTD

Hello world

Beta Alpha

];

Load

     TextID,

     concat(Parts,'',PartID) as Done

resident TEXTS group by TextID;

sivarajs
Specialist II
Specialist II
Author

Hi Miguel,

Thanks that is working fine but valueloop throwing error in script

How can i acheive the same in script

Regards

sivaraj

fah18
Contributor II
Contributor II

Hi,

Did you find any solution to this? Im trying to use this for my excel Fields.. Any help? 

ArjunChandra
Contributor II
Contributor II

@swuehl , good Work. Forgive me for my incapability to understand your solution. I have few doubts

1) I tried to load Inline data 1st and then TEXTs  Table and then resident table, why it is throwing error?

2) Why F1 field not coming into dashboard?

3) How to remove ' of ' if I have data like this ' International Inst of Tech'