If String Contains Space In The End or In The Beginning

Hello,

I want to detect spaces in the string if the spaces are in the end or in the beginning.

My string can be:
AAA

or

AAA BBB

So, I dont want to detect middle spaces. I just want to detect ends and beginnings.

I’ll be appreciated if you can help me.

Thanks.

yourString.Trim()

Hi,

Thanks for your answer. But I dont want to fix my string. I want to detect it.

You can use StartsWith and EndsWith.
For example, using C# you would do something like: myString.StartsWith(' ') || myString.EndsWith(' ')

Thank you so much, it worked !

1 Like

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