开发者

Regular expression to modify a line that contains only a single word at the start

开发者 https://www.devze.com 2022-12-22 02:36 出处:网络
I have a text file in which any line that star开发者_StackOverflow中文版ts with a single word and has no other characters after that should be enclosed inside caret characters.

I have a text file in which any line that star开发者_StackOverflow中文版ts with a single word and has no other characters after that should be enclosed inside caret characters.

For example, a line that contains only the following 6 characters (plus the newline):

France

should be replaced with a line that consists of only the following 8 characters (plus the newline):

^France^

Is there a Regular Expression I could use in the Find/Replace feature of my text editor (Jedit) to make these modifications to the file?


Regex to find lines with a single word:

^(\w+)$

replace with:

^$1^
0

精彩评论

暂无评论...
验证码 换一张
取 消