Split and substring like java

Split and substring like java

  

Hi everyone...

How would you go around to collect the first letter of each word in a string, as in to receive an abbreviation?

String: "Java Script Object Notation"
Wanted result: "JSON"

Thanks

Hi Affa,

There's no straightforward way to do that, but you could either use a String_Split (from the Text extension) and subsequently use a For Each over the output and Substr (built-in function, Text folder) to get the first character, or you could use a Regex_Replace (also from the Text extension) with a pattern like "(?<=\w)[\w ]?" (and a replace pattern of "").

Solution

Kilian Hekhuis wrote:

Hi Affa,

There's no straightforward way to do that, but you could either use a String_Split (from the Text extension) and subsequently use a For Each over the output and Substr (built-in function, Text folder) to get the first character, or you could use a Regex_Replace (also from the Text extension) with a pattern like "(?<=\w)[\w ]?" (and a replace pattern of "").

Yeah @Kilian, thanks for the answer. I just got solution from my problem, I used the logic to get first character after Space from first sentence with Condition if character be found Space in one sentence and I put the first character from sentence plus first character from second word of sentence.

File attached if somebody want to use my solution.

Thanks.

Solution

Hello Sukardi, 

    I'm trying to do exactly the same thing but i don't understand what you did in your server action "SplitCharacter".
My local variable contains 2 words (ex: Atok Sukardi ) and i want only AS at the end. How do you check every single characters to know if there is a blank space in the localVariable ??

Thank you,