-1

I am creating HTML files from text files (HTML bible). I would like to enclose ALL numbers 0-9, with definition list tags <DT> & <DD>, so that the following:

1 In the beginning...(example)..
2 And God said...(example)..
15 Adam was....(example)..
26 Cain was...(example)..
38 Enoch was...(example)..

would look like:

<DT>1<DD> In the beginning...(example)..
<DT>2<DD> And God said...(example)..
<DT>15<DD> Adam was....(example)..
<DT>26<DD> Cain was...(example)..
<DT>38<DD> Enoch was...(example)..

Being that this is the bible, I have HUNDREDS of THOUSANDS of numbers (verses) to place in tags, so I really need this shortcut. I'm, using EditPlus and know nothing about these other "scripts" you guys use. (sorry- Im a nube...), So I need a RegEx (or Find/Replace: something easy: "Ctrl+H".)
I can 'open' and 'close' the DL /DL lists by hand after I get all the verse numbers between & tags.

(I wish I was as smart as you guys! :)

chris85
  • 23,846
  • 7
  • 34
  • 51
RonRay
  • 1
  • 1
  • See, http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks, for future postings and double check your spelling. You also should include the code you've tried so far. – chris85 Feb 15 '17 at 18:15
  • search for (\d+) and replace with
    $1
    enclosed ALL letter "D"s in the tags. "Numbers" were not enclosed in tags...?
    – RonRay Feb 15 '17 at 18:22
  • Chris85: I tried 0-9 (without brackets) before- EditPlus didn't recognize it; I just added the brackets [0-9] (as per your suggestion), and EP still does not find it. – RonRay Feb 15 '17 at 18:47
  • Maybe EditPlus doesn't support all of regex. Maybe try Notepad++ or look for another text editor that supports the parts of regex you need to use. – Whothehellisthat Feb 15 '17 at 19:31
  • search ([0-9]+) and replace with
    \1
    works!!! WoW, Thanks!
    – RonRay Feb 15 '17 at 20:02
  • Is there any way to limit this to the beginning of a line...? There are a lot of numbers withing the verses as well. If not, I'll just do this one at a time, which is WAY faster than manually inserting every tag. THANKS!!! – RonRay Feb 15 '17 at 20:03
  • @RonRay Please see answer below if that answers the question please mark the answer as accepted. – chris85 Feb 15 '17 at 21:00

1 Answers1

0

[0-9] is a number, + is a quantifier meaning one or more of the preceding character/group, and () is a capture group which will capture what is inside. So you could use

([0-9]+) 

to capture all numbers. The value will be in

\1

You can use a ^ to ensure you are at the start of the line.

^([0-9]+)

You can read more here about regex operations supported by EditPlus, http://editplus.info/wiki/Regular_expression_syntax.

chris85
  • 23,846
  • 7
  • 34
  • 51