Bug 36753

Summary: method subst() on RegExp "^" should work different
Product: Regexp Reporter: Pavel Vojtechovsky <pvojtechovsk>
Component: OtherAssignee: Jakarta Notifications Mailing List <notifications>
Status: NEW ---    
Severity: normal CC: pvojtechovsk
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Pavel Vojtechovsky 2005-09-21 08:16:36 UTC
code:

RE loRE = new RE("^");
String loResult = loRE.subst("abc", "x");

returns loResult=="xbc" //replaces first character
but I would expect it should return loResult=="xabc" //inserts before first 
character.

I agree that it is probably not defined by RE specification, but it seems to 
me similar to another case:

RE loRE = new RE("$");
String loResult = loRE.subst("abc", "x");

which returns (as I would expect) loResult=="abcx"
Comment 1 Jeremy Brown 2005-11-17 17:35:56 UTC
I agree.  This behavior is different from both Perl substitutions and the
String.replaceAll function in Java 1.4.