21
Views
13
Comments
String ending with , or .
Question

How to identify given string is ending with anyspecial character or not?

As of now I am using regex search. But now sure how to check for only end of the string.


Basically I need to remove these special char from the end of the string

Champion
Rank: #99

Hi,


You can use the Index function like this:


If index starting from end is 0 that means that is found.


Hope this can help.


Best regards,

Ricardo M Pereira

Rank: #389

Ankita Kulkarni wrote:

How to identify given string is ending with anyspecial character or not?

As of now I am using regex search. But now sure how to check for only end of the string.

 

 Is it any special chars OR only . ,

Hi Ankita,

Try this Regex Expression

[a-zA-Z0-9](.*[a-zA-Z0-9])?$

Let me know if it works for you.

Regards,

Samiksha

Champion
Rank: #134

Hi Ankita,

can you please confirm one thing only check ending with any special character  or any thing where in the string.

Please refer below character if you want to restrict the special characters

https://www.outsystems.com/forums/discussion/58583/how-to-check-special-characters-in-a-string/

Hope this will help you :)

- AV

Thanks

Champion
Rank: #134

Hi Ankita,

Please refer this post if you want to remove special characters

https://www.outsystems.com/forums/discussion/55651/remove-special-characters/

Please let me know if you have any query

- AV

Thanks


mvp_badge
MVP
Rank: #75

Hi Ankita,

You can use the Regex_Replace server action available in the Text Extension for the mentioned use case.

See this sample app - RegexDemo (RWA)

The implementation also works in case of string ending with multiple dot and comma symbol

Used Regex Pattern:

"[,.]+$"

Hope this helps you!


Regards,

Benjith Sam

Rank: #68

Hi Ankita,


For future reference, there is a component called Regex How To that allows you to test regular expressions, see how to implement Regex both on Server side and Client side and see the most common patterns.

Using the same pattern as described by Benjith:


"[,.]+$"

 

you can see how it works both on Server side and Client side.


If you are developing a Mobile or Reactive application, you probably want to use a client action so it can work offline and it is more performant as it avoids going to the server.


Hope it helps.


Cheers,

João

Rank: #257

I understand coming up with great solutions, but why not just keep it simple? That typically works best.

Var2 = Substr(Var1,Length(Var1)-1,1)

Var1 = If(Var2 = "." or Var2 = ",", Substr(Var1, 0, Length(Var1)-1), Var1)