Replace <space> on 0 between [ ] inside a string

Hello Knimers,

How could I replace the space characters on 0 between the smybols in the following string?

DEBUG ( 0) [ 811] 03/01/2021 06:36:25 Received line: BREQ

Thank you in advance!

Roland

Hi @rolandnemeth ,
I’m not sure I understood correctly. do you want to get to the following string?
DEBUG ( 0) [0811] 03/01/2021 06:36:25 Received line: BREQ
If yes, you can do this by using “String Manipulation” with “regexReplace” like this:
image

2 Likes

Hi @FtmhRahimi,

Thanks for the fast response.

Exactly, if the number of space characters is only 1 between the square brackets.

I mean (have not tested) your solution works, if only 1 space character can be found between the brackets.

But the situation is not so simple, the number of space characters can be more then 1 inside the bracket.

Best regards,
Roland

Hi @rolandnemeth,

So just add a “+” after the white space char in @FtmhRahimi’s regex:
regexReplace($text$, "\\[\\s+(\\d)\\]", "[$1]")

:blush:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.