Sort by

recency

|

89 Discussions

|

  • + 0 comments

    pretty hardcoded but still works

    sed -E 's/([0-9]{4})\s([0-9]{4})\s([0-9]{4})\s([0-9]{4})/\4 \3 \2 \1/g'
    
  • + 0 comments

    Test case 3 does NOT confirm to the problem specification:

    3
    6692 0561 4520 3826
    6425 7911 2003 7865
    4033 3854 0338 5166
    
  • + 1 comment

    This works

    • sed -E "s/(\d+) (\d+) (\d+) (\d+)/\4 \3 \2 \1/"
  • + 1 comment

    -E saves me :)

    sed -E 's/([0-9]{4} )([0-9]{4} )([0-9]{4} )([0-9]{4})/\4 \3\2\1/g'

  • + 0 comments
    sed -E 's/([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/\4 \3 \2 \1/' 
    

    The back-reference. \1, \2, \3, \4, etc. refer to the first, second, third, etc. parenthesized group in the regular expression.

    OR

    sed -E "s/([0-9]{4}) ([0-9]{4}) ([0-9]{4}) ([0-9]{4})/\4 \3 \2 \1/"
    

    {n} means "exactly n of the preceding expression" in a regular expression.