Concatenation: Putting Multiple Strings Together

Modified on Fri, Dec 1, 2023 at 2:56 PM

Putting Strings Together


Concatenation is the process of putting together multiple Strings into one long String.


What is a String?

A "String" is simply a bit of text.  It is the data type for "text string".  In Genesis SIS a String is any field containing text data, as opposed to numbers, Booleans, Dates, Timestamps and Binaries.


Concatenation Functions

In Expression Language there are 4 concatenation functions:

FunctionExplanation
concatConcatenate two Strings together and return a String. rw:concat(String s1, String s2)
concat3Concatenate three Strings together; return a String:  rw:concat3(s1, s2, s3) 
concat4Concatenate four Strings together; return a String:  rw:concat4(s1, s2, s3, s4)
concat5Concatenate five Strings together; return a String:  rw:concat4(s1, s2, s3, s4, s5)


Example

In this example, we want to take the course code, course description, section #, semester code and period and put those all together into a single, short summary String:


What are the pieces that are going to be assembled into the single String?

  1. Course code (e.g. 10375)
  2. A slash ('/')
  3. Section # (e.g. 4)
  4. Course description ("English 3 Honors")
  5. An open parend ('(')
  6. Semester code ('FY')
  7. A comma (',')
  8. Period #
  9. A closed parend 


That is a total of 9 items.  The "largest" of the concatenation functions is concat5 which only takes 5 elements.  How can 9 elements be assembled into a single String?


Source elements:   What we want to produce:

The answer is that calls to concatenation functions - and all other functions in Expression Language - can be 'nested':  any one or even all of the elements can be calls to additional functions.   Let's assemble a concatenation expression that will assemble all 9 elements into a single final String:


  1. Using "concat5" as the first function, start with the course code:   rw:concat5(row.courseCode,
  2. Add a slash ('/'):  This has to be a literal:   rw:concat5(row.courseCode, '/',
  3. Add the Section #:   rw:concat5(row.courseCode, '/',row.section,
  4. Now there needs to be a space between the section # and the course description:  every character in the final String needs to be accounted for, so an actual space needs to be added here as the 4th element:  rw:concat5(row.courseCode, '/',row.section,' ',
  5. Now, the 5th element is the last element in the initial function call, but there are still at least 6 more items to add to the String:  this is where another concat5 function call is embedded:    rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription,
  6. Following the course description, there is a space and an open parend ('(').  There is a space between the end of the course description and the open parend, but that space gets incorporated in the String for the open parend:  rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription, '  (',
  7. Now the semester code is attached, followed by a comma:   
    1. rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription, '  (',row.semesterCode,
    2. rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription, '  (',row.semester, ',',
  8. That makes 4 elements in the second concat5 function call, but again there are still 2 additional items that need to be added.  Again, a nested call to a concat function must be added.  The first item to the new concat call is the period #: rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription, '  (',row.semester, ',',concat(row.period,
  9. Finally, the closing parend can be added:  rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription, '  (',row.semester, ',',rw:concat(row.period,')'
  10. Now the only thing necessary is to make sure there are the right number of closing parends: one of the final concat call, one for the second concat call and one for the first or outermost concat call:  rw:concat5(row.courseCode, '/',row.section.'  ',rw:concat5(row.courseDescription, '  (',row.semester, ',',rw:concat(row.period,')')))


In total, there are 3 concat calls:  concat5 , concat5 and concat; there are 5 Columns: row.courseCode, row.section, row.courseDescription, row.semester and row.period; and finally 5 literals:  '/', ' ', '{', ' ', '}'

All of that is assembled to generate one composite String:    course/section  description (semester, period)


Numbers and Strings in Concatenation

Number fields, like section #, are automatically converted to a String in a concatenation.  


Concatenation Functions are Literal

The four concatenation functions are literal:  they put together only what they 'see':  they do not add spaces or anything else.   When you combine items, as above, you must supply the spaces, newline characters, commas, periods and all other punctuation (with the exception of decimal points in numbers).  


Adding Newline Characters

A newline character causes the String to skip to the next line.  Newlines can be inserted directly into Strings via a literal:


This will place the last name on the line above the first name, inserting a literal newline between the two:

rw:concat3(row.lastName,'

',row.firstName) 


To insert the newline, type a single quote ' hit return, then type a closing single quote: '




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article