Regex to match only uppercase “words” with some exceptions

前端 未结 6 2034
面向向阳花
面向向阳花 2020-12-02 20:26

I have technical strings as the following:

\"The thing P1 must connect to the J236 thing in the Foo position.\"

I would like to match with

6条回答
  •  一向
    一向 (楼主)
    2020-12-02 21:08

    For the first case you propose you can use: '[[:blank:]]+[A-Z0-9]+[[:blank:]]+', for example:

    echo "The thing P1 must connect to the J236 thing in the Foo position" | grep -oE '[[:blank:]]+[A-Z0-9]+[[:blank:]]+'

    In the second case maybe you need to use something else and not a regex, maybe a script with a dictionary of technical words...

    Cheers, Fernando

提交回复
热议问题