Home > Net >  How to grep everything in between from curl response?
How to grep everything in between from curl response?

Time:01-02

I have a curl response like this:

<textarea >params:
email: [email protected]
name : john </textarea>
</textarea>

I want to grep everything between params: and </textarea> .

I have tried with (?<=params:)(?s).*(?=\<\/textarea), but is not working. Is my regex wrong?

CodePudding user response:

A more robust solution would be using something like pup:

cat <<'EOF' | pup 'textarea text{}'
<textarea >params:
email: [email protected]
name : john </textarea>
EOF

resulting in

params:
email: [email protected]
name : john 

CodePudding user response:

Using GNU awk:

gawk -F '<textarea' -v RS='</textarea>' '$NF ~ /params:/ { gsub(/.*params:\s*/, "", $NF); print $NF }'

CodePudding user response:

params:[\s\S]*</textarea>
  • Related