Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Regular expression expanding and matching
On Nov 25, 4:45pm, Mark van Dijk wrote:
}
} if [[ $somestring -pcre-match \d{4}${todaysday} ]]; then
} echo "somestring matches today"
} elif [[ $somestring -pcre-match \d{4}${yesterday} ]]; then
} echo "somestring matches yesterday"
} fi
}
} Apparently there is no expansion of ${todaysday} and ${yesterday}.
No, that's not what's happening here. What's happening is that the
backslash is being removed by the shell command line parser before
the regular expression is passed to the PCRE parser. Try
if [[ $somestring -pcre-match \\d{4}${todaysday} ]]; then
echo "somestring matches today"
elif [[ $somestring -pcre-match \\d{4}${yesterday} ]]; then
echo "somestring matches yesterday"
fi
} +./zshtest:9> [[ $somestring -pcre-match \d{4}${todaysday} ]]
} +./zshtest:11> [[ $somestring -pcre-match \d{4}${yesterday} ]]
Hmm, there's something slighly off about that XTRACE output. Change
the condition to -ef and you can see the real expansion:
+./zshtest:9> [[ 121125 -ef 'd{4}25' ]]
+./zshtest:11> [[ 121125 -ef 'd{4}24' ]]
I'm not sure where the trace output is generated in the case of an infix
condition operator that comes from a module, but I think there is a bug.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author