问题描述
当我进行派生列转换时,我有一个包含文件名的SourceFile列,命名约定包含一个日期。
When I'm doing a derived column transformation, I have a SourceFile column that contains the name of the file, and the naming convention includes a date.
I' m使用此表达式查找文件名的日期门户网站:
I'm using this expression to find the date portal of the filename:
regexExtract(SourceFile,'[0-9] {8}')
regexExtract(SourceFile, '[0-9]{8}')
文件名如下所示:TEST_STUFF_COMMITMENTS_20190604.txt
The filename looks like this: TEST_STUFF_COMMITMENTS_20190604.txt
当我对此进行数据预览时,我得到以下异常:
When I do a data preview on this, I get this exception:
java.lang.IndexOutOfBoundsException :java.util.regex.Matcher.group没有组1
(Matcher.java:538)
java.lang.IndexOutOfBoundsException: No group 1
at java.util.regex.Matcher.group(Matcher.java:538)
如果我将表达式更改为此,我得到没有异常(并且所有值都为TRUE):
If I change the expression to this, I get no exception (and all values are TRUE):
regexMatch(SourceFile,'[0-9] {8}')
regexMatch(SourceFile, '[0-9]{8}')
我是也试过这个:
iif(regexMatch(SourceFile,'[0-9] {8}'),regexExtract(SourceFile,'[0-9] {8}'))
iif(regexMatch(SourceFile, '[0-9]{8}'),regexExtract(SourceFile, '[0-9]{8}'))
但我仍然得到例外。
but I still get the exception.
也许某处有错误?
Perhaps there's a bug somewhere?
Mike
推荐答案
regexExtract ( SourceFile ,
'[0-9] { 8}', 0 )
这篇关于ADF Dataflow regexReplace生成异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!