c# - Match a regex and reverse the matches within the target string -
c# - Match a regex and reverse the matches within the target string - based on this question regex \d+(?:-\d+)+ match 10-3-1 , 5-0 . example: this 10-3-1 string after performing matching , reversing, want this: this 1-3-10 string notice 10-3-1 should become 1-3-10 , not normal string reverse result in 1-3-01. a basic algorithm be: extract match string. "10-3-1" split match segments "-" character. you have list of elements. ["10","3","1"] reverse list. ["1","3","10"] join elements of array "-" character. "1-3-10" replace match newly joined string. c# regex string reverse