How do you “debug” a regular expression with sed?

后端 未结 8 1569
日久生厌
日久生厌 2021-01-31 08:19

I\'m trying to use a regexp using sed. I\'ve tested my regex with kiki, a gnome application to test regexpd, and it works in kiki.

date: 2010-10-29          


        
8条回答
  •  孤街浪徒
    2021-01-31 09:16

    In sed you need to escape the curly braces. "s/author:\s[0-9]\{11\};//g" should work.

    Sed has no debug capability. To test you simplify at the command line iteratively until you get something to work and then build back up.

    command line input:

    $ echo 'xx a: 00123 b: 5432' | sed -e 's/a:\s[0-9]\{5\}//'
    

    command line output:

    xx  b: 5432
    

提交回复
热议问题