Remove the first space

Dear everybody,
How to remove the first space of the string, not all Spaces, only the first space in the string is removed, and the length of the string is different.
Thanks in advance.

BRs
Banksy

Hi @Banksy,

When you say “remove the first space of the string”, I am assuming you mean the first space, whereever it appears (i.e. not just if it is the first character of the string).

If that interpretation is correct, then I think this regex replacement should do the job.

Configure String Replacer as follows:

Pattern:
([^ ]*)[ ](.*)

Replacement text:
$1$2

This “captures” everything that isn’t a space up to (but not including) the first space, and returns it ‘$1’, then ignores a space and then returns everything following that space `$2’

image

3 Likes

Hi @takbb
My master, long time no see. I mean remove only the space in the first position of the string, and if there is no space in the first position it stays the same.
like this:
image

BRs
Banksy

Hi @Banksy , yes it’s been a while!

To remove just the first space, if present do the above but change the pattern and replacement to this:

Pattern:
[ ]{0,1}(.*)

Replacement text:
$1

This should ignore a single space if it exists and capture, and return, everything else.

Alternatively, you could use the same regex replacement with String Manipulation, as follows:

regexReplace($column1$,"[ ]{0,1}(.*)" ,"$1" )

2 Likes

Hi @takbb ,
Thank you so much my master. You helped me again.

BRs
Banksy

1 Like

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