Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
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 (32.1k 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
0 votes
1 answer
asked Oct 23, 2019 in Java by Anvi (10.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers

500 comments

108k users

Browse Categories

...