String methods

String methods can be used to return new strings or a list of strings that have beenĀ modified in some way or to test the string for various conditions and return a Boolean. Some useful methods are as follows:

We can create a simple playbook that will utilize some of these methods in a single task:

--- 
- name: demo the filters 
  hosts: localhost 
  gather_facts: false 
    
  tasks: 
    - name: string methods 
      debug: 
        msg: "{{ 'foo bar baz'.upper().split() }}" 

The output is shown in the following screenshot:

As these are object methods, we need to access them with dot notation, rather than with a filter via |.