Space insertion after numbers in a string

I've a list with different strings and want to insert a space between numbers and text:

String (example): "TextA, TextB, 35897TextC"
I want to insert a space between 35897 and TextC => "TextA, TextB, 35897 TextC".
The length of the strings, the appeareance of the numbers, TextA, TextB, TextC and the numbers vary.

I tried the String Replacer node, but wasn't able to make this work. Do you may have any suggestions?

Many thanks in advance!



you want to use the String Manipulator node with the regexReplace function.

This takes three arguments,

- The first argument is the input string,

- The second argument is a regular expression.

   In this case, you want "(\\d+)(\\D)", the double "\\" is to escape "\" in java.

   This will select a group containing 1 or more numbers (\\d+), followed by any non-digit.

- The third argument is what you want to replace the expressions identified by the regular expression with. 

    In this case it's "$1 $2".

    $1 is what's caught in the first group, the digits,

     $2 is what's caught in the second group, the non-digit.

    The space in between is the space you are asking to add.

I've taken you example and put it into a workflow. Hope it works.




By the way, String replacer will work also, you need to check regular expression, and here the "\\" should be replaced by a single "\", so (\d+)(\D) to catch, and $1 $2 as the replacement, and check the all occurances.


Hi David,

awesome! MANY thanks for your support - this works perfectly!