Regex Split support for optional patterns?

Is it possible to use optional groups in patterns (with data matching, and present)?

For example:
(.+)(?: [([1-3])])?$ matches: something, but produces an error message: Execute failed: String value can’t be null.

Could it be a missing value? (Or a collection of StringCells?)

Stack trace:
java.lang.NullPointerException: String value can’t be null.
at org.knime.base.node.preproc.regexsplit.RegexSplitNodeModel$1.getCells(
at org.knime.core.node.ExecutionContext.createColumnRearrangeTable(
at org.knime.base.node.preproc.regexsplit.RegexSplitNodeModel.execute(
at org.knime.core.node.NodeModel.execute(
at org.knime.core.node.NodeModel.executeModel(
at org.knime.core.node.Node.execute(
at org.knime.core.node.workflow.SingleNodeContainer.executeNode(
at org.knime.core.node.workflow.SingleNodeContainer.access$1(
at org.knime.core.node.workflow.SingleNodeContainer$
at java.util.concurrent.Executors$ Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at Source)
at org.knime.core.util.ThreadPool$
at org.knime.core.util.ThreadPool$

It looks like the pattern like this: (.)+ is also not properly handled, as it produces only a g. (The non-grouping (?:, ) seems to be creating new columns, I am not sure how intentional it is.)

Thanks for the problem report. There are two problems with the node: (1) it creates columns for non-capturing groups and (2) it throws the reported NPE for optional groups. Both problems were fixed and will be available in v2.1.

I can’t see a problem with (.)+ matching only g though. The parentheses match one character, whereby g is the character the matched last. Maybe the documentation on java regexp helps here?

Thanks again!

You are really good. :slight_smile: And absolutely right. I have not checked properly the documentation. (I thought it is possible to get the individual groups from the match and those would be the values in the result column. My wrong.)
Thanks, gabor