split last keyword in parboiled2 avoid greedy match

18 views
Skip to first unread message

cjue...@gmail.com

unread,
Aug 19, 2016, 10:05:26 AM8/19/16
to parboiled2.org User List

hi ,I have a regex like this:


```scala

private final val queryPattern = Pattern.compile("(?s)(.*)\\s+as\\s+(\\w+)\\s*”)

def getQueryDataConfig(sql: String) = {

  val matchSql = queryPattern.matcher(sql)

  if (matchSql.matches()) {

   (matchSql.group(1), matchSql.group(2))

  } else {

    throw new IllegalArgumentException(s"query sql error :$sql,we need select * from xxx as tempTableName")

  }

}

```


my input is :"select uid as id ,name ,age from a left join b on a.uid = b.uid as my_test" , i want result is tuple: ("select uid as id ,name ,age from a left join b on a.uid = b.uid","my_test")


I want to split my input string using last `as` ,how can i do in parboiled2 ,thanks


best regards

Reply all
Reply to author
Forward
0 new messages