Issue while parsing Complex Regular expression in YAML file

[1]{9,430}$”

Tried other options like


  1. a-zA-Z0-9-+.#$%&~*/=?^_ '"\! ↩︎

Try this

  '^[a-zA-Z0-9-+.#$%&~*/=?^_''\"!]{9,430}$'

In "single-quoted style" only the single-quote must be escaped ('')
https://yaml.org/spec/1.2/spec.html#id2788097

For example (occurrences left out)

    - debug:
        msg: OK
      loop: ['a', '+', '}']
      when: item is match(context_regex)
      vars:
        context_regex: '^[a-zA-Z0-9-+.#$%&~*/=?^_''\"!]$'

gives

    ok: [localhost] => (item=a) => {
        "msg": "OK"
    }
    ok: [localhost] => (item=+) => {
        "msg": "OK"
    }
    skipping: [localhost] => (item=})

HTH,

  -vlado

The backslash must be escaped too (\\). For example,

    - debug:
        msg: OK
      loop: [' ', "'", '\', '"', '!', '}']
        
      when: item is match(context_regex)
      vars:
        context_regex: '^[a-zA-Z0-9-+.#$%&~*/=?^_ ''\\"!]$'

gives

    ok: [localhost] => (item= ) => {
        "msg": "OK"
    }
    ok: [localhost] => (item=') => {
        "msg": "OK"
    }
    ok: [localhost] => (item=\) => {
        "msg": "OK"
    }
    ok: [localhost] => (item=") => {
        "msg": "OK"
    }
    ok: [localhost] => (item=!) => {
        "msg": "OK"
    }
    skipping: [localhost] => (item=})

HTH,

  -vlado