laurikari / tre

The approximate regex matching library and agrep command line tool.
Other
799 stars 133 forks source link

Escape sequences are not recognized within bracket expressions #20

Open nathanhaigh opened 10 years ago

nathanhaigh commented 10 years ago

I want to match all non-tab characters at the start, or end, of a string. For example, I have the following tab-delimited string where the two columns also contain a space: a aataaa\tbbbtb bb.

If I want to match the first column, I should be able to do:

echo -e "a aataaa\tbbbtb bb" | tre-agrep --color --show-position -e '^[^\t]+'
0-4:a aa</font>taaa    bbbtb bb

It should match anything with in not a tab. However, as you can see, it matches upto, but not including the "t" rather than the tab.

Similarly, trying to match the last column:

echo -e "a aataaa\tbbbtb bb" | tre-agrep --color --show-position -e '[^\t]+$'
13-17:a aataaa  bbbtb bb
nathanhaigh commented 10 years ago

On further investigation, it appears that other special escape sequences may also match their non-escaped character too.