You are here: PSPad forum > English discussion forum > I am looking for a special pattern "Bible Verse Regex"
Posted by: vbr | Date: 2021-04-11 17:37 | IP: IP Logged
of course, the pattern you need depends on your input data and the matches you want to get; good, that you found a pattern you are almost satisfied with or which you can tweak further.
The possible reason to use a pattern with "non-basic" Latin letters could be yout initial example with: "Kapł";
won't match ł in this case, as it works in a non-unicode mode here, i.e. it matches only the following characters:
0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
Note, that it matches basic Latin letters, an unterscore _ and also the digits 0-9, which might or might not be what you need.
Posted by: pspad | Date: 2021-04-11 17:55 | IP: IP Logged
In this case is necessary to add all non basic chars individually like: [\wł] and add all missing chars.
Posted by: Haunebu | Date: 2021-04-11 18:27 | IP: IP Logged
I do not use Latin characters, only Polish [A-Ża-ż]
Edited 1 time(s). Last edit at 2021-04-11 18:28 by Haunebu.
Posted by: Haunebu | Date: 2021-04-11 18:30 | IP: IP Logged
My pattern is wrong, for example, does not match verses in parentheses and separation in the form of a semicolon, and additional verse numbers after a spaces and a semicolon.
() ===> (any verse)
(verse ; )
(verse ;verse2 ,20, 29, 56)
Edited 4 time(s). Last edit at 2021-04-11 18:33 by Haunebu.
Posted by: therium | Date: 2021-04-30 12:42 | IP: IP Logged
Your original expression is incorrect as it did not escape escapable regex characters like a dash.
Original regex: ([\d ]*[a-zA-Z]+( \d*:\d*)?)(( - )| )?(((\d* )?[a-zA-Z]+ )?\d*([:-]+\d*)?)
When searching for dashes, periods, and some other characters, they must be escaped like this: [\.\-\]
Your corrected regex:
([\d ]*[a-zA-Z]+( \d*:\d*)?)(( \- )| )?(((\d* )?[a-zA-Z]+ )?\d*([:\-]+\d*)?)
For more information on escaping characters try this search:
To test your regex, use one of these regex testers:
You type in your regex, then your text to search, and it will help you find something that works on the proper text. Some of these regex testers allow you to have an account so you can save your regex's.
Edited 1 time(s). Last edit at 2021-04-30 12:43 by therium.