Regular expression search replace in Sublime Text 2

前端 未结 6 1525
鱼传尺愫
鱼传尺愫 2020-11-27 09:10

I\'m looking to do search replace with regular expressions in Sublime Text 2. The documentation on this is rather anemic. Specifically, I want to do a replace on groups, so

6条回答
  •  再見小時候
    2020-11-27 09:43

    By the way, in the question above:

    For:

    Hello, my name is bob
    

    Find part:

    my name is (\w)+
    

    With replace part:

    my name used to be \1
    

    Would return:

    Hello, my name used to be b
    

    Change find part to:

    my name is (\w+)
    

    And replace will be what you expect:

    Hello, my name used to be bob
    

    While (\w)+ will match "bob", it is not the grouping you want for replacement.

提交回复
热议问题