Sort by

recency

|

90 Discussions

|

  • + 0 comments

    As simple as that.

    sed -E 's/(\d{4}) (\d{4}) (\d{4}) (\d{4})/\4 \3 \2 \1/g'

  • + 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/"
    • + 0 comments

      as far as I know the 'sed ' only supports BRE and ERE, and neither of them support perl character classes like: \d ??

  • + 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'

    • + 1 comment

      -E and -e what is difference??????

      • + 0 comments

        -E lets you use extended regular expressions, so you don’t need to escape things like {}, +, or (). -e lets you write one or more sed commands — it’s used to pass multiple commands to sed. So: -E = easier regex -e = multiple commands