Skip to content

Commit

Permalink
Fix regex to allow @copy to contain nested parens
Browse files Browse the repository at this point in the history
  • Loading branch information
ttscoff committed Oct 16, 2021
1 parent 2f79bfa commit 922d3f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.7

- Fix regex to allow nested parens in @copy

## 1.2.6

- New build process
Expand Down
6 changes: 3 additions & 3 deletions qq
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
QQ_VERSION=1.2.6
QQ_VERSION=1.2.7
# Usage:
# Ask a question using natural language
# $ qq [search terms]
Expand Down Expand Up @@ -236,9 +236,9 @@ __qq () {
echo -n "$(__qc yellow)Q: $(__qc white)"
echo "$QUESTION"|sed -E 's/([^\?])$/\1?/'
echo -n "$(__qc yellow)A: $(__qc white)"
cat "$ANSWER_FILE"|sed -E 's/@\([^\)]+\) ?//g'|sed -E 's/@copy\(([^\)]+)\)/\1/'|sed -E 's/@open\(([^\)+]*)\)/Related URL: \1/'|sed -E 's/@[^\( ]+ ?//g' # |sed -E 's/^[ ]*|[ ]*$//g'
cat "$ANSWER_FILE"|sed -E 's/@\([^\)]+\) ?//g'|sed -E 's/@copy\((.+)\)/\1/'|sed -E 's/@open\(([^\)+]*)\)/Related URL: \1/'|sed -E 's/@[^\( ]+ ?//g' # |sed -E 's/^[ ]*|[ ]*$//g'
if [[ `cat "$ANSWER_FILE"|grep -E '@copy\('` && $HAS_COPIED_TEXT == false ]]; then
cat "$ANSWER_FILE"|grep '@copy('|sed -E 's/.*@copy\(([^\)]+)\).*/\1/'|tr -d '\n'|pbcopy
cat "$ANSWER_FILE"|grep '@copy('|sed -E 's/.*@copy\((.+)\).*/\1/'|tr -d '\n'|pbcopy
echo -e "\n$(__qc green)Example in clipboard"
HAS_COPIED_TEXT=true
fi
Expand Down

0 comments on commit 922d3f9

Please sign in to comment.