Advertisement
tivasyk

searching for <TAGS> in a string

Jul 25th, 2019
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.37 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # tivasyk <tivasyk@gmail.com>
  3. # Launch to test: ./test "<TAG_1>Test<TAG_2>"
  4.  
  5. TEST="$@"
  6. printf "Received line: «${TEST}»\n"
  7.  
  8. while [[ ${TEST} =~ "<"[A-Z_0-9]*">" ]]; do
  9.     TAG="<${TEST#*<}"
  10.     TAG="${TAG%%>*}>"
  11.     printf "Found a tag: ${TAG}, deleting...\n"
  12.     TEST="${TEST/${TAG}/}"
  13. done
  14.  
  15. printf "Result without tags: «${TEST}»\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement