简体   繁体   中英

How to replace text wrapped by tabs using regular expression and Sublime Text?

I have the following pattern:

SomeText    SomeText    SomeText
SomeProp    SomeProp    SomeProp
Property    Property    Property

Each word are separated by a tab \\t .

I need to replace the second/middle word by prefix + middle word + suffix .

I use this regex to select the second word:

\t(\w)*\t

But when I try to replace it:

\t prefix\1suffix \t

It does not work.

You're repeating the capture group; only the last word character will be captured. Place the operator inside of the group construct to quantify the \\w token instead of the group.

Use Ctrl + H to open the Search and Replace , enable Regular Expression if you haven't ..

Find What: \t(\w+)\t
Replace With: \tprefix\1suffix\t

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM