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
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
Ricardo Pereira wrote:
Hi Ricardo,
I am thinking of using, string_split(Text, index(text,",", searchfromend:true).Will this split all the variable in to list seperating by , or only 2.
Ankita Kulkarni wrote:
Is it any special chars OR only . ,
Sourav Pasari wrote:
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
Samiksha Manekar wrote:
You can validate you string on https://regexr.com/
ex
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
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
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!
Benjith Sam
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
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)