I have a string with same pattern like this:
../assets/
../../assets/
../../../assets/
I'm using regex to find the ../
pattern using:
(\.\./)
My purpose is to replace all the ../
become root/
, and all the string above will become like this root/assets/
Is there a way to do that with some kind recursive pattern with regex?
Update
I'm using C#
string content1 = "../assets";
string content2 = "../../assets";
string content3 = "../../../assets";
string pattern1 = "(\.\./)";
string pattern2 = "(\.\./\.\./)";
string pattern3 = "(\.\./\.\./\.\./)";
// All the result is "root/assets"
content1 = Regex.Replace(content1, pattern1, "root/");
content2 = Regex.Replace(content2, pattern2, "root/");
content3 = Regex.Replace(content3, pattern3, "root/");