Prepend - to the first word of each line

14 views
Skip to first unread message

nir...@gmail.com

unread,
Jan 12, 2024, 7:09:05 PMJan 12
to TextSoap
I am not sure where I am going wrong. I would like to prepend a hyper to the first word of each line. I am have the "m" option selected(for each line), and am searching for the first non white space character.

The search only shows the first match, the first character of the first line ,but none subsequent.

Niran Sabanathan

CleanShot 2024-01-12 at 08.13.06.jpg

Mark Munz

unread,
Jan 13, 2024, 7:39:03 PMJan 13
to text...@googlegroups.com
To understand what is happening here, let's break down the expression: ^(\w)

^ is anchored to the beginning of the line (option:m)
(\w) the first character to match is a word character after the anchor. So only line 1 matches, because the others have whitespace, then a word.

Instead, use something like this:

Find: ^(\s*)(\w)
Here we start at the beginning of the line (^) then allow for zero or more whitespace (\s*), capturing the result, finally capturing the first word character (\w)

Replace: $1-$2
We preserve any whitespace found, then insert our hyphen at the beginning of the word match.


--
You received this message because you are subscribed to the Google Groups "TextSoap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to textsoap+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/textsoap/5b6f6542-e3d3-4ac8-8a9a-e8dea827f6f6n%40googlegroups.com.


--
Mark Munz
unmarked software
https://textsoap.com/

nir...@gmail.com

unread,
Jan 14, 2024, 11:03:08 AMJan 14
to TextSoap
Thanks.
Reply all
Reply to author
Forward
0 new messages