[ 
https://issues.apache.org/jira/browse/FLINK-10281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16608767#comment-16608767
 ] 

ASF GitHub Bot commented on FLINK-10281:
----------------------------------------

hequn8128 commented on a change in pull request #6671: [FLINK-10281] [table] 
Fix string literal parsing in Table API
URL: https://github.com/apache/flink/pull/6671#discussion_r216206820
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/ExpressionParser.scala
 ##########
 @@ -185,13 +185,18 @@ object ExpressionParser extends JavaTokenParsers with 
PackratParsers {
           }
       }
 
-  lazy val singleQuoteStringLiteral: Parser[Expression] =
-    ("'" + """([^'\p{Cntrl}\\]|\\[\\'"bfnrt]|\\u[a-fA-F0-9]{4})*""" + "'").r 
^^ {
-      str => Literal(str.substring(1, str.length - 1))
-    }
+  // string with single quotes such as 'It''s me.'
+  lazy val singleQuoteStringLiteral: Parser[Expression] = "'((?:''|[^'])*)'".r 
^^ {
 
 Review comment:
   Should we also add `?:` in the outer matches? Same for 
`doubleQuoteStringLiteral `.
   ((?:''|[^'])*)-> (?:(?:''|[^'])*)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Table function parse regular expression contains backslash failed
> -----------------------------------------------------------------
>
>                 Key: FLINK-10281
>                 URL: https://issues.apache.org/jira/browse/FLINK-10281
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API & SQL
>            Reporter: vinoyang
>            Assignee: vinoyang
>            Priority: Major
>              Labels: pull-request-available
>
> for example,  regular expression matches text ("\w") or number ("\d") :
> {code:java}
> testAllApis(
>   "foothebar".regexExtract("foo([\\w]+)", 1),       //OK, the method got 
> 'foo([\w]+)'
>   "'foothebar'.regexExtract('foo([\\\\w]+)', 1)",   //failed, the method got 
> 'foo([\\w]+)' returns "", but if pass 'foo([\\w]+)' would get compile error.
>   "REGEX_EXTRACT('foothebar', 'foo([\\\\w]+)', 1)", //OK, the method got 
> 'foo([\w]+)' but must pass four '\'
>   "thebar"
> )
> {code}
> the "similar to" function has the same issue.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to