17
Views
8
Comments
Solved
String split

Hi All,

PFA,

Wanted to split string and assign to 4  local variables,separator " "

If the string is ex new Delhi

then name1=New

Name2=Delhi

If the string is ex new Delhi India Delhi India

Then Only name1,Name2,Name3,Name4 to populated


String_Split1.oml
2021-11-19 11-12-44
Rui Mendes
Solution

@Preeti zade , as @Mihai Melencu mentioned before, you shouldn't use a space to split the string. 

However, if you really want to use a space, just replace the comma with one.I'm also attaching a demo showing how you can check the value of a specific position within the list.

To see it in action: enter the string using a comma as a separator and click 'Go' to generate the split list. Once the list is generated, you can click on any string to see its value.

Check.oml
UserImage.jpg
Preeti zade

Hi Rui,

Thank you for the reply,

Actually I need to separate these list into 4 names to pass to api fields(Apa has name1,name2,name3,name4 fields.(Full name into 4 names )So I have done below approach,

Regards

CheckSplit.oml
2021-11-19 11-12-44
Rui Mendes


Thanks for the update, glad it worked out! 

2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Preeti zade ,

You should not split by every space, because "New Delhi" must stay together as one name.

You need a separator that clearly separates the names, for example comma ,, pipe |, or semicolon ;.

UserImage.jpg
Preeti zade

Yes but they want delimiter space as of now

But the requirement is to separate into multiple names and pass to api,full name to be split

2021-11-19 11-12-44
Rui Mendes

Based on your question and the example, I think you might be confusing records with record lists. Check out the attached example to see how it's done 

Test.oml
UserImage.jpg
Preeti zade

Hi Rui,

Thank you for the reply,

But I am looking If user enters full name withe space ,I want to separate each straing and pass in name1,name2,name3 and name4 api fields,If he enters two words with separator space then only name1 and nam2 will go,

Regards

2021-11-19 11-12-44
Rui Mendes
Solution

@Preeti zade , as @Mihai Melencu mentioned before, you shouldn't use a space to split the string. 

However, if you really want to use a space, just replace the comma with one.I'm also attaching a demo showing how you can check the value of a specific position within the list.

To see it in action: enter the string using a comma as a separator and click 'Go' to generate the split list. Once the list is generated, you can click on any string to see its value.

Check.oml
UserImage.jpg
Preeti zade

Hi Rui,

Thank you for the reply,

Actually I need to separate these list into 4 names to pass to api fields(Apa has name1,name2,name3,name4 fields.(Full name into 4 names )So I have done below approach,

Regards

CheckSplit.oml
2021-11-19 11-12-44
Rui Mendes


Thanks for the update, glad it worked out! 

2024-10-05 13-30-20
Huy Hoang The

First use trim to remove space first and last
Second use string split then we have list and you ignore list[0]. Additionally, if an error occurs, please replace space by comma before use string split.

Another thing I'm thinking about is whether names can have more than one word.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.