Search upto first occurence of the pattern

I have the output of command as below

/ps/was-ps/woa/woa_runtime/profiles
/ps/was-ps/woa12/woa_runtime/profiles
/pas/ec1/ukpl/woa_runtime/profiles

From this paths, I need to find the lines upto first occurence of woa or first occuerence of woa*.

Output needed:
/ps/was-ps/woa/
/ps/was-ps/woa12/
/pas/ec1/ukpl/woa_runtime/

Is there anyway to do this in ansible regex_search or anyother filter.

Given the output lines are stored in the list "mylines", try this

    - debug:
        msg: "{{ mylines|
                 map('regex_replace', myregex, myreplace)|
                 list }}"
      vars:
        myregex: '^(.*?)woa(.*?)/(.*)$'
        myreplace: '\g<1>woa\g<2>/'

HTH,

  -vlado

Thank you for your response, this is giving output as below

\/ps/was-ps/woa/woa_runtime/profiles
\/ps/was-ps/woa12/woa_runtime/profiles
\/pas/ec1/ukpl/woa_runtime/profiles

The playbook below works for me

cat playbook.yml

- hosts: localhost
  vars:
    mylines:
      - /ps/was-ps/woa/woa_runtime/profiles
      - /ps/was-ps/woa12/woa_runtime/profiles
      - /pas/ec1/ukpl/woa_runtime/profiles
  tasks:
    - debug:
        msg: "{{ mylines|map('regex_replace', myregex, myreplace)|list }}"
      vars:
        myregex: '^(.*?)woa(.*?)/(.*)$'
        myreplace: '\g<1>woa\g<2>/'

ansible-playbook playbook.yml

...
TASK [debug] ***
ok: [localhost] => {
    "msg": [
        "/ps/was-ps/woa/",
        "/ps/was-ps/woa12/",
        "/pas/ec1/ukpl/woa_runtime/"
    ]
}
...

HTH,
  -vlado