Regex capture every occurrence of a word within two delimiters

前端 未结 4 1541
自闭症患者
自闭症患者 2021-01-05 15:47

Say I have a long string of text, and I want to capture every time the word this is mentioned within rounded brackets. How could I do that? The following patt

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 16:38

    I implemented the regex to enclose all alphanumberic characters using regex below:

    # cat testfile 
    aabc a1 +++    xyz 20   30 =40  -r
    # cat testfile | sed -e "s/\([[:alnum:]]\{1,\}\)/
    \1/g"
    
    aabc 
    a1 +++    
    xyz 
    20   
    30 =
    40  -
    r
    #
    

    Hope it helps.

提交回复
热议问题