+1 vote
1 view
in Salesforce by (11.9k points)

Using Apex, I want to split a string and then rejoin it with the 'AND' operator as the separator.

I split the string successfully but having an issue in rejoining it.

String [] ideaSearchText = searchText.Split(' ');

 // How to rejoin the array of strings with 'AND'?

How can I do this?

1 Answer

+1 vote
by (31.6k points)
edited by

You can join an array of strings by using String.join( ) for String[]

String input = 'valueOne valueTwo valueThree'; 

String[] values = input.split(' '); 

String result = String.join( values, ' AND ' );

Are you interested in learning Salesforce! Have a look at interesting video on SQL:

Related questions

0 votes
1 answer
asked Oct 23, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Sep 11, 2019 in Java by Krishna (2.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...