Cut a string of characters

Hi,

I need to cut the left part of the character string to derive the Key name of S3 from the signed upload URL.

I have to delete the first part (server1.s3.wasabi.com/)

I tried to use SubString but it ask me:

Position and lenght. (Lenght can be variable so doesn’t works)

I tried to make Replace using a single space and it works. But after, using “trim” cannot take out the space.

Which is the best method to get rid of the left part of the string using wappler formatters?

Thank you

Roberto

Hey Roberto,

You can use split to separate the string into an array of items and then use the index to get the piece you want:

For example, this will get you the first piece:

your-value.split('.')[0]
1 Like

Yes. I used it in the second part…

For example, being this the address:

https://s3.eu-central-1.wasabisys.com/aol23/11/4/2c501622-5ece-4e07-82ae-27e998dac3fa.JPG?x-amz-acl=&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=CDI22PS201IQI0OCP888%2F20201009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201009T155140Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=5f9166c421bdcfce6057fc52d57c4f9067184f3b73e10a03efe166c07e974546

With replacing with a space https://s3.eu-central-1.wasabisys.com/
I got:

aol23/11/4/2c501622-5ece-4e07-82ae-27e998dac3fa.JPG?x-amz-acl=&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=CDI22PS201IQI0OCP888%2F20201009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201009T155140Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=5f9166c421bdcfce6057fc52d57c4f9067184f3b73e10a03efe166c07e974546

Then I used split using $ as character, so [0] position I got

aol23/11/4/2c501622-5ece-4e07-82ae-27e998dac3fa.JPG

then I try to trim the remaining address to take out the initial empty space but doesn’t works…

Ahh, the story evolves. :slight_smile:

Okay, so I’m assuming this is the string you are starting with:

https://s3.eu-central-1.wasabisys.com/aol23/11/4/2c501622-5ece-4e07-82ae-27e998dac3fa.JPG?x-amz-acl=&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=CDI22PS201IQI0OCP888%2F20201009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201009T155140Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=5f9166c421bdcfce6057fc52d57c4f9067184f3b73e10a03efe166c07e974546

correct?

If so, what text are you trying to extract?

Yes the story evolves :wink:

aol23/11/4/2c501622-5ece-4e07-82ae-27e998dac3fa.JPG is the text I need to get

Okay, so it seems like you are saying you achieved that, but then want to remove an "initial empty space"...I'm not seeing any space though??? Using trim as your final step, you can remove any leading/trailing white space. Is there some space in the middle I'm not seeing?

It is what I did but it continue to store in the db the initial space… now trying to re-do the server connect action if something mabye need refresh…

But what expression are you using for "replacing with a space" ? I also don't see any spaces?

sorry in the copy/paste it disappear…

aol23/11/4/2c501622-5ece-4e07-82ae-27e998dac3fa.JPG?x-amz-acl=&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=CDI22PS201IQI0OCP888%2F20201009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201009T155140Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=5f9166c421bdcfce6057fc52d57c4f9067184f3b73e10a03efe166c07e974546

I used:

Well if you paste code please wrap it in backticks so we can see it! Use: ` around your code so we can see your exact expression.

OK sorry I had to make SC again…

this is the server connect:

Then I set a Value to replace the first part (the address of the server) with a space)

After I set another Value to trim it…
Schermata 2020-10-09 alle 18.54.43

Last Value I slit it to make it an array and take only the first position
Schermata 2020-10-09 alle 18.56.00

and here it insert the Key name in the Db

but unfortunately it insert with the initial space… also if I sued the Trim.
there is something I m making error?

Here in Navicat you can see the space of the last file comparing the previous one where I delete manually the space:

Schermata 2020-10-09 alle 18.59.15

Well … edit the code and remove the space you added there :slight_smile:

So just remove it:

removespaces

how do you get this windows where yo can edit?

if you were a beautiful girl I would kiss you on the mouth …

but I think a heartfelt thanks is still appreciated;)

1 Like