Create a string having N times of a character

Hello,

Can a string be created having say a character “A” for N times? I mean create a string 5 times “A” i.e. “AAAAA”.

Thanks.

How long the string is expected to be. Will N be a very large number? In the example shared it is just 1 digit (5)
Is the letter to be repeated just any one character (mainly alphabet) or any other characters and multiple characters are possible?

1 Like

N will be dynamic. And the character will be space or alphabet.

Regards,

Rajan Pachchigar
O2C Domain Lead, Domain Specialist (Agile delivery model | Commercial track)

Upcoming OOO: None

Holcim Services (South Asia) Limited
Reliable Tech Park , Empire Tower,
17th Floor South Block ,C & D Wing,
Airoli, Navi Mumbai- 400708

Mobile +91 99877 57109
rajan.pachchigar@lafargeholcim.com
www.lafargeholcim.com

Thanks. Could you update what you mean by dynamic? Is N likely to be at the most 1 digit (0-9) , 2 digit(0-99) or more than that?

2 Likes

N will be derived from some calculations and it could be two digits.

Regards,

Rajan Pachchigar
O2C Domain Lead, Domain Specialist (Agile delivery model | Commercial track)

Upcoming OOO: None

Holcim Services (South Asia) Limited
Reliable Tech Park , Empire Tower,
17th Floor South Block ,C & D Wing,
Airoli, Navi Mumbai- 400708

Mobile +91 99877 57109
rajan.pachchigar@lafargeholcim.com
www.lafargeholcim.com

Thank you. I am sure there will be more ingenious ways to achieve the needful. I hope, the below two could trigger some relevant ideas.

A) A basic , crude but working approach.

SUBSTITUTE(LEFT(“IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII”,[String Length]),“I”, [String Letter])
Here [String Length] is the desired output string length number ( N) , [String Letter] is the letter of which a new string needs to be built. The default string built here is of letter I and 50 characters long. One could concatenate or simply have default string length of 100 for N greater than 50

  1. The below expression works for s string length upto 15

SUBSTITUTE(NUMBER(POWER(10, [String Length]))-1,9,[String Letter])

One could concatenate further as required. But the expression will grow longer.

Both the above will work on alphabets. I am unsure what results one expects by spaces. As a space as input will return space, as per my understanding.

3 Likes

I have to add say 5 space characters as preceding into a string say “ABCD” to make it " ABCD".

image.png

Please clearly describe what you want to accomplish so we can offer a specific suggestion.

1 Like

Hello,

str1 = “ABCD”
N=5

Then str1 = " ABCD", i.e. I want to add 5 space characters at the beginning of str1.

If N=9,

Then str1 = " ABCD", i.e. I want to add 9 space characters at the beginning of str1.

To add leading spaces to a Text value:

RIGHT(("     " & [text]), [length])

To add leading zeros to a Number, producing a Text value:

RIGHT(("00000" & [number]), [length])

The leading value (" " and "00000" above) must be at least as long as the length of the intended result.

There is no way to generate a character series of an arbitrary length; you must know the maximum possible length.

2 Likes