Selecting the last word of a line

29 views
Skip to first unread message

Francisco Hirsch

unread,
Feb 3, 2020, 11:02:55 AM2/3/20
to bbe...@googlegroups.com
I have a file with several lines of text.
How can I select the last word of the line and inserting a tab in front of it?
Thanks in advance,
Francisco
--
Lic. Francisco A. Hirsch







Sam Hathaway

unread,
Feb 3, 2020, 11:28:25 AM2/3/20
to bbe...@googlegroups.com

It’s a little hairy, but this seems to work:

Find: ((?:.|\n)*\W)(\w+)
Replace: \1\t\2

Hope this helps.
-sam

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/16C08EDF-62CB-483E-9B9B-5DE0E523EFFA%40gmail.com.

Fletcher Sandbeck

unread,
Feb 3, 2020, 11:30:28 AM2/3/20
to bbe...@googlegroups.com
Open the Find dialog and enter the following patterns and do a replace all. This finds one or more non-whitespace characters \S+ at the end of a line $ and replaces them with a tab \t and the found text \1.

Find: (\S+)$
Replace: \t\1

Also the following variant replaces the white space \s+ in front of the word with the tab so you don't end up with any extra spaces and it works better if there already is a tab before the final word.

Find: \s+(\S+)$
Replace: \t\1

Hope this helps,

[fletcher]


Francisco Hirsch

unread,
Feb 3, 2020, 1:23:29 PM2/3/20
to lspe...@gmail.com, bbe...@googlegroups.com
Great!
Gracias, Thanks!,
Francisco
--
Lic. Francisco A. Hirsch

On 3 Feb 2020, at 13:12, Luis Speciale <lspe...@gmail.com> wrote:

No responde precisamente a tu pregunta, pero es una pista sólida a futuro

https://regex101.com/r/Czpo6E/1


Reply all
Reply to author
Forward
0 new messages