zjffdu commented on a change in pull request #3799:
URL: https://github.com/apache/zeppelin/pull/3799#discussion_r439183252



##########
File path: 
zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphTextParser.java
##########
@@ -67,41 +67,105 @@ public String getScriptText() {
     }
   }
 
-  private static Pattern REPL_PATTERN =
-          Pattern.compile("(\\s*)%([\\w\\.]+)(\\(.*?\\))?.*", Pattern.DOTALL);
+  private static Pattern REPL_PATTERN = 
Pattern.compile("^(\\s*)%(\\w+(?:\\.\\w+)*)");
 
   public static ParseResult parse(String text) {
     Map<String, String> localProperties = new HashMap<>();
-    String intpText = null;
+    String intpText = "";
     String scriptText = null;
 
     Matcher matcher = REPL_PATTERN.matcher(text);
-    if (matcher.matches()) {
+    if (matcher.find()) {
       String headingSpace = matcher.group(1);
       intpText = matcher.group(2);
-      if (matcher.groupCount() == 3 && matcher.group(3) != null) {
-        String localPropertiesText = matcher.group(3);
-        String[] splits = localPropertiesText.substring(1, 
localPropertiesText.length() - 1)
-                .split(",");
-        for (String split : splits) {
-          String[] kv = split.split("=");
-          if (StringUtils.isBlank(split) || kv.length == 0) {
-            continue;
-          }
-          if (kv.length > 2) {
-            throw new RuntimeException("Invalid paragraph properties format: " 
+ split);
-          }
-          if (kv.length == 1) {
-            localProperties.put(kv[0].trim(), kv[0].trim());
-          } else {
-            localProperties.put(kv[0].trim(), kv[1].trim());
+      int startPos = headingSpace.length() + intpText.length() + 1;

Review comment:
       Put the local property extraction logics into a separate function for 
more readability. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to