Perl substitute from right to left

I have a string:

I want to replace the string in the right side for result:

When using Perl string replace pattern

myString = "";
replacedString = "";
resultString = null;
Perl5Util perl=new Perl5Util();
resultString =perl.substitute("s/." + replacedString + "//o",myString );

However, Perl replaces the string "" from left to right with the result

Is there any way to change the behaviour?


Match the end of the string with $.

perl.substitute("s/." + replacedString + "$//o",myString );

You should probably escape that . as well, since . matches any character. You might need two backslashes (\\.) otherwise the java string will treat it as a special character. If you don't want to escape the . you use the character selection syntax [.].

perl.substitute("s/\\." + replacedString + "$//o",myString );

Need Your Help

How to make @each observer trigger just once


I have an each observer which observes an array property. I have an action that goes through the array and sets that property, so it gets fired multiple times. I am wondering if I could make it tri...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.