2016-12-07 11 views
2

動作しない、 赤方偏移は、このようなエラーが返されます。赤方偏移/正規表現(否定先読みが)

-- Find records that do not start with abc 
select * from table_a where column_a ~ '^(?!abc).+$' 

Error: PG::InternalError: ERROR: Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression: '^(?>>>HERE>>>!abc).+$'. DETAIL: ----------------------------------------------- error: Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression: '^(?>>>HERE>>>!abc).+$'. code: 8002 context: T_regexp_init query: 1039510 location: funcs_expr.cpp:130

を赤方偏移がないように見えます否定的な先読みを認識しない...
Redshiftで使用できる方法はありますか?

+0

あなたの意向は何ですか?あなたは一致する必要がありますか? 'abc'と等しくない文字列ですか? Redshiftの正規表現の味はPOSIXなので、どのような視点も使用できません。 –

+0

ご意見ありがとうございます。私は私の意図を示すために質問を更新しました。しかし、利用可能なルックアラウンドはありません...? :( – sora

+0

) 'abc'で始まらないエントリにマッチさせたいのですが、ここで' 'column_a! ''^abc''を試してみてください。(否定を正しく使う方法はわかりません) –

答えて

4

Acc。 Amazon Redshift documentationには、~オペレータで使用できる正規表現がPOSIX標準に準拠しています。つまり、は対応策がありませんです。これらのパターンには(?!...)(?<!...)構造を使用することはできません。

文字列がパターンで始まらない場合は、文字列を一致させたいと思うようです。この場合、否定正規表現演算子のバージョン!~を使用することができます。

where column_a !~ '^abc' 
関連する問題