Hello All,
In Softanza, to remove a substring from left or right you can use RemoveFromLeft() and RemoveFromRight() functions.
o1 = new stzString("let's say welcome to everyone!")
o1.RemoveFromLeft("let's say ")
? o1.Content() # --> welcome to everyone!
But when right-to-left strings are used, this can be confusing, since left is no longer at the start of the string,
nor the right is at the end!
Hence, if you want to retrieve a substring from the beginning of a right-to-left arabic text ("هذه" in the following example), you should inverse the orientation and use RemoveFromRight() instead...
o1 = new stzString("هذه الكلمات الّتي سوف تبقى")
? o1.NRightChars(4) #--> "هذه "
o1.RemoveFromRight("هذه ")
? o1.Content() # --> "الكلمات الّتي سوف تبقى"
To avoid this complication, Softanza provides a more general (semantic) solution working both for left-to-right and right-to-left strings: the RemoveFromStart() and RemoveFromEnd() functions...
o1 = new stzString("let's say welcome to everyone!")
o1.RemoveFromStart("let's say ")
? o1.Content() # --> welcome to everyone!
and the same code for arabic:
o1 = new stzString("هذه الكلمات الّتي سوف تبقى")
o1.RemoveFromStart("هذه ")
? o1.Content() # --> "الكلمات الّتي سوف تبقى"
Here is a snapshot of the code working on my machine:
All the best,
Mansour
--
---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/b44a0c58-33a8-48a8-aa12-3c387e90923fn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/fa781dc5-91a3-42c9-a46e-b8eca8cecce3n%40googlegroups.com.