The Problem
I have a load of strings in this form:-
str1/str2
str3/str4/str5
There can be any number of segments. I would like to do a regex search and replace to get the output:-
str1/str2 , str1->str2
str3/str4/str5 , str3->str4->str5
My strings are actually in the form [a-z|_]+
My attempt
Match with:-
((?:(?:[a-z|_])\/?)+)
Replace with:-
$1 , $1
This is nearly right, but I’d need to do a second search and replace to change the /‘s to ->‘s.
Can I achieve this with a single regex? Or does it depend on the engine I’m using and it’s backreference capabilities? (I’m using the search and replace functionality in aptana).
Rather than a repeating group does Aptana support a global modifier? This works in JavaScript:
Also, I guess you meant your pattern should also allow numbers.