![]() |
#1 |
Enthusiast
![]() Posts: 48
Karma: 10
Join Date: Aug 2017
Device: none
|
Regex Beginning and End of Tag
Can Regex understand the end of a line or the beginning of a line that has text on it? I want to be able to insert something at the beginning of each line where the text starts and at the end of the line where the text ends. I'm thinking Regex can do this. I've used it so far and it's a very cool guy.
My process is this: I copy pasta lots of text into a text editor, then I copy pasta that into Sigil and I'd like to use regex to do some hefty formatting inside of Sigil. Last edited by d351r3d; 06-04-2020 at 07:56 PM. |
![]() |
![]() |
![]() |
#2 |
Zealot
![]() Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
I think it is ^ and $ in regex. ^ means the start of a line and $ means the end.
What you want is the end of a line or the beginning of a line that has text on it, which I think close to ^.+$ |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Enthusiast
![]() Posts: 48
Karma: 10
Join Date: Aug 2017
Device: none
|
Quote:
Code:
^.+$ Code:
<p></p> Code:
I really like sandwiches! Code:
<p>I really like sandwiches</p> Last edited by d351r3d; 06-05-2020 at 09:06 AM. |
|
![]() |
![]() |
![]() |
#4 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,882
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
NO!
You did not insert any captured data (the \1 ) <p>\1</p> You did not even CAPTURE any data ![]() Put a ( ) pair around the part you want to capture (if there is a real ( or ) in the template: escape those: \( or \) |
![]() |
![]() |
![]() |
#5 |
Enthusiast
![]() Posts: 48
Karma: 10
Join Date: Aug 2017
Device: none
|
So you can't do what I'm trying to do with Regex? Like regex can't be like "oh that's the beginning of a line with content, let me just put something before that and there's the end of a line, let me just put something after that line with content."
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |||
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,518
Karma: 167912829
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Quote:
Quote:
HOWEVER: Please note that this will match EVERY line in your document no matter what it is. In the case of your sample code: Code:
(^.+$) Code:
<p>\1</p> Last edited by DNSB; 06-05-2020 at 09:37 PM. |
|||
![]() |
![]() |
![]() |
#7 | |
Enthusiast
![]() Posts: 48
Karma: 10
Join Date: Aug 2017
Device: none
|
[QUOTE=DNSB;3996728]
Quote:
|
|
![]() |
![]() |
![]() |
#8 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 681
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
This site: https://regexr.com/
is really useful for working out regex codes. Has good references, cheatsheets, and a live test. Seems to be compatible with Sigil's version of regex. |
![]() |
![]() |
![]() |
Tags |
end of line, formatting, regex sigil, text |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Move date from beginning to end of title w/ regex? | melba.d | Library Management | 2 | 08-04-2018 01:58 AM |
Wondering if there is a way to remove end tag with beginning tag | LadyKate | Editor | 5 | 06-29-2016 04:32 PM |
Regex to search at beginning of line | kakkalla | Sigil | 30 | 06-03-2013 03:08 PM |
TOC at the beginning or end? | sassanik | Writers' Corner | 15 | 08-16-2012 06:08 PM |
The beginning of the end for DRM? | plib | News | 111 | 05-25-2012 09:14 AM |