Regex find and replace a digit

To find only a single digit (such as “1”, or “2”) and replace (only) it, you have to add a plus after \d.

Something like:

(\d+)

(to find it) and

\1

to replace it.

For example you have to add a new element to these lines

1 some first text 
3 some other text
8 other text

You can use this regex

find: (\d+) replace: \n\1

as a result you will get


1 some first text 

3 some other text

8 other text

Regex for first lowercase letter

If you have en ebook that split badly a paragraph, you can try (to merge the bad splitted paragraph), as find

</p>\n\n\s\s<p>([a-z])

so that a paragraph beginning with a lowercase word be merged with the previous one.

But in Calibre editor you must check “case sensitive”, otherwise [a-z] will be read as [A-Z], and all first letters (lower and upper case) will be selected.

And as replace you could try

 \1

In this way you keep whatever letter is found with ([a-z]) in the result.

Regex for “space”

It can happen that you want replace a double space before <p>: use the \s. I.g. to replace

,</p>

<p>

You should use this find: ,</p>\n\n\s\s</p>

link from outside to a part of a file

pdf

It is possible to link a page of a pdf, with the following syntax:

file:///your-path-here/your-pdf-filename-here.pdf#pag=[the-page-number]

or, if the file is within your localhost folder

http://localhost/your-path-here/your-pdf-filename-here.pdf#pag=[the-page-number]

epub

It is possible to link to a given location of an epub file, i.g. with calibre viewer, with a code like the following

file:///your-path-here/your-epub-filename.epub?open_at=epubcfi(/10/2/4/2/132/18/1:65)

You can get the string after open_at (in the above case: epubcfi(/10/2/4/2/132/18/1:65) in the calibre viewer, this way:

  • right click
  • -> go to
  • -> location
  • -> current location (above in the window) : copy

video file

with VLC you can use this code

vlc file:///my-path/my-video.mp4 --start-time=90

where ’90’ are the seconds (after the start of video).

I didn’t manage, so far, to open a video with such a code from a browser.

audio file

You ca do it in several ways. With play (sox) in Linux you can use a code setting not only the start time, but the end one as well:

play '/your-path/your-file.ogg' trim 5:18 =7:01

where 5:18 is the start time, and 7:01 the end one (=7.01 and not = 7:01)