You are here: PSPad forum > English discussion forum > Re: I am looking for a special pattern "Bible Verse Regex"

Re: I am looking for a special pattern "Bible Verse Regex"

Goto Page: 1 2 3 Next

#1 I am looking for a special pattern "Bible Verse Regex"

Posted by: Haunebu | Date: 2021-04-09 08:04 | IP: IP Logged

I am looking for a special pattern "Bible Verse Regex"

([\d ]*[a-zA-Z]+( \d*:\d*)?)(( - )| )?(((\d* )?[a-zA-Z]+ )?\d*([:-]+\d*)?)

// zero of more digit(s) or a space
[\d ]*

// any number of upper/lowercase letters
[a-zA-Z]+

// a space followed by an optional any number of digits, a colon,
// and any number of digits again
( \d*:\d*)?)

// an optional hyphen with a space either side, or a space.
(( - )| )

Unfortunately, there are matching issues:
Example:
Filip. 4:13
Filipian 4:13
Jana 5:28, 29
(Rzym. 8:35-37)
Ps. 120:1; 121:1-8
(Kapł. 17:11-14; Dzieje 15:20, 29)
(1 Piotra 5:9)

Options: Reply | Quote | Up ^


#2 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: Haunebu | Date: 2021-04-09 08:26 | IP: IP Logged

This pattern is better, but the characters are not exactly matched.
(?:\d|I{1,3})?\s?\w{2,}\.?\s*\d{1,}\:\d{1,}-?,?\d{0,2}(?:,\d{0,2}){0,2}

Options: Reply | Quote | Up ^


#3 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: pspad | Date: 2021-04-09 13:19 | IP: IP Logged

What characters are not exactly matched?

instead of the \w try [a-žA-Ž0-9]

(?:\d|I{1,3})?\s?[a-žA-Ž0-9]{2,}\.?\s*\d{1,}\:\d{1,}-?,?\d{0,2}(?:,\d{0,2}){0,2}

Edited 2 time(s). Last edit at 2021-04-09 13:22 by pspad.

Options: Reply | Quote | Up ^


#4 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: Haunebu | Date: 2021-04-09 16:24 | IP: IP Logged

Enable highlighting in PSPad if this feature is available and it will detect all mismatched characters
(
)
;

Options: Reply | Quote | Up ^


#5 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: pspad | Date: 2021-04-09 16:39 | IP: IP Logged

Haunebu:
Enable highlighting in PSPad if this feature is available and it will detect all mismatched characters
(
)
;

Sorry, but I don't understand.

Options: Reply | Quote | Up ^


#6 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: Haunebu | Date: 2021-04-09 18:22 | IP: IP Logged

For example, it does not detect this char in this verse:
(;, 29)

(Kapł. 17:11-14; Dzieje 15:20, 29)

Edited 1 time(s). Last edit at 2021-04-09 18:22 by Haunebu.

Options: Reply | Quote | Up ^


#7 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: pspad | Date: 2021-04-09 19:45 | IP: IP Logged

This one sould be found whole at once?
Ps. 120:1; 121:1-8

This one should be found including "1"?
1 Piotra 5:9

Try this expression:
([a-žA-Ž0-9.]+\s+)+([0-9:.,;-]+\s{0,})+[0-9]

looking for at least one: ([a-žA-Ž0-9.]+\s+)+
followed by at least one: ([0-9:.,;-]+\s{0,})+
ennding with: [0-9]

"+" means one or more repeating

Edited 1 time(s). Last edit at 2021-04-09 19:51 by pspad.

Options: Reply | Quote | Up ^


#8 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: Haunebu | Date: 2021-04-09 22:25 | IP: IP Logged

([a-žA-Ž0-9.]+\s+)+([0-9:.,;-]+\s{0,})+[0-9]

(Kzn 1:7; Am 5:8)
Invalid match the parenthesis and semicolon
regex101.com

Edited 2 time(s). Last edit at 2021-04-09 22:27 by Haunebu.

Options: Reply | Quote | Up ^


#9 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: Haunebu | Date: 2021-04-09 22:37 | IP: IP Logged

Completely defective regex, because it matches everything, a special pattern must carefully recognize versesjvgccdco 1 Piotra 5:9

It's still better because it does not detect incorrect text, but still incorrect
Full / Combine verse
(Rdz 1:9, 10, 13; Neh 9:6; Dz 4:24; 14:15; Obj 14:7)
(?:\d|I{1,3})?\s?\w{2,}\.?\s*\d{1,}\:\d{1,}-?,?\d{0,2}(?:,\d{0,2}){0,2}

Edited 2 time(s). Last edit at 2021-04-09 22:40 by Haunebu.

Options: Reply | Quote | Up ^


#10 Re: I am looking for a special pattern "Bible Verse Regex"

Posted by: pspad | Date: 2021-04-10 02:14 | IP: IP Logged

Only you know what you want to match. You put few examples only without any text around.
We can't see into your head

Options: Reply | Quote | Up ^


Goto Page: 1 2 3 Next





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR