replaceFirst

Description: Replaces the first occurrence of one literal String or regular expression within the Subject with another String.

Subject Type: String

Arguments:

  • Search String : The String (literal or regular expression pattern) to find within the Subject

  • Replacement : The value to replace Search String with

Return Type: String

Examples: If the "filename" attribute has the value "a brand new filename.txt", then the following Expressions will provide the following results:

Expression

Value

${filename:replaceFirst('a', 'the')}

the brand new filename.txt

${filename:replaceFirst('[br]', 'g')}

a grand new filename.txt

${filename:replaceFirst('XYZ', 'ZZZ')}

a brand new filename.txt

${filename:replaceFirst('\w{8}', 'book')}

a brand new book.txt