Regex to find the beginning of line

447 views
Skip to first unread message

abbas zahid

unread,
Apr 17, 2020, 9:34:03 AM4/17/20
to TextSoap
I am trying to find beginning of line using ^ but this is not working on TextSoap however this does work on sublimetext

For example

Dog ate my food

A dog at my food


Find: ^


Replace: Text


Result: 

Text Dog ate my food

Text A dog at my food



Please advice



Mark Munz

unread,
Apr 17, 2020, 11:50:11 AM4/17/20
to TextSoap
Using ICU regular expressions, ^ is used as an anchor. It does not specifically match any character in your text. Same is true for $ - these anchors are used in conjunction with various character matching.

Additionally, ^ can represent both beginning of text and beginning of line based on the options set for the expression. $ - works similar with end of line/text anchoring.

So, how do you match at the beginning of a line and insert text?
First, make sure to set the Matches Lines (m) under options. This is available for both interactive and find actions within cleaners.
Then search for an least one character, like this:

Find: ^.
Replace: Text $0

. (dot) matches any character (except a newline)
$0 in the replace represents the entire match found – in this case, the single character.



--
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/ae53bad2-e6a8-437c-becf-f002d402d8d8%40googlegroups.com.


--
Mark Munz
unmarked software
http://www.unmarked.com/

abbas zahid

unread,
Apr 17, 2020, 12:02:37 PM4/17/20
to TextSoap
Thanks for the explanation, it worked but for the first line only. I need this to be done on multiple lines.


With your suggestion I was able to get:

Text Dog ate my food

A dog at my food


How do I make it work on all the lines?

On Friday, April 17, 2020 at 8:50:11 PM UTC+5, Mark Munz wrote:
Using ICU regular expressions, ^ is used as an anchor. It does not specifically match any character in your text. Same is true for $ - these anchors are used in conjunction with various character matching.

Additionally, ^ can represent both beginning of text and beginning of line based on the options set for the expression. $ - works similar with end of line/text anchoring.

So, how do you match at the beginning of a line and insert text?
First, make sure to set the Matches Lines (m) under options. This is available for both interactive and find actions within cleaners.
Then search for an least one character, like this:

Find: ^.
Replace: Text $0

. (dot) matches any character (except a newline)
$0 in the replace represents the entire match found – in this case, the single character.



On Fri, Apr 17, 2020 at 6:34 AM abbas zahid <thecoo...@gmail.com> wrote:
I am trying to find beginning of line using ^ but this is not working on TextSoap however this does work on sublimetext

For example

Dog ate my food

A dog at my food


Find: ^


Replace: Text


Result: 

Text Dog ate my food

Text A dog at my food



Please advice



--
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 text...@googlegroups.com.

abbas zahid

unread,
Apr 17, 2020, 12:06:48 PM4/17/20
to TextSoap
Ignore my last message I was able to change all the lines by enabling Match Lines(m)

Thank you so muhc
Reply all
Reply to author
Forward
0 new messages