Softanza String: Left and Right VS Start and End

40 views
Skip to first unread message

Mansour Ayouni

unread,
Nov 13, 2022, 4:03:07 PM11/13/22
to The Ring Programming Language

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:


image.png


All the best,

Mansour

Mahmoud Fayed

unread,
Nov 14, 2022, 2:51:50 AM11/14/22
to The Ring Programming Language
Hello Mansour

Nice feature, Thanks for sharing :D

I like the idea of RemoveFromStart()

By the way, I see that You are using Windows 11
What is your review for this version? Is Ring and it's libraries working as expected?

Greetings,
Mahmoud

Mansour Ayouni

unread,
Nov 14, 2022, 7:30:57 AM11/14/22
to Mahmoud Fayed, The Ring Programming Language
Hello Mahmoud,

Thank you for your kind words!

Yes, Ring works as expected in Windows 11. I felt like Softanza is more performant than before in some heavy functions...

It may be due to my move from Ring 1.16 to 1.17, or due to Windows 11, or to both of them!

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.

Mahmoud Fayed

unread,
Nov 14, 2022, 8:24:08 AM11/14/22
to The Ring Programming Language
Hello Mansour

>> "I felt like Softanza is more performant than before in some heavy functions"

Also, another reason could be Defragmentation : https://en.wikipedia.org/wiki/Defragmentation

Since You are using a new operating system, maybe your files doesn't suffer from too much fragmentation

Greetings,
Mahmoud

Mansour Ayouni

unread,
Nov 14, 2022, 11:03:33 AM11/14/22
to Mahmoud Fayed, The Ring Programming Language
Reply all
Reply to author
Forward
0 new messages