Last active
November 11, 2021 01:57
-
-
Save pedropolidoro/e9bac748c7970d91ecb688dd57506a92 to your computer and use it in GitHub Desktop.
Regular expression for separate and recognize musical chords symbos when mixed with lyrics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\b((?:[A-G]|vii|VII|vi|VI|v|V|iv|IV|iii|III|ii|II|i|I)[#b♯♭]?(?:m(?:i(?:n(?:or)?)?)?|\+|½?dim|º|°|⁰|◦|⸰|○|⚬|∆|Δ|△|Ø|ø|⌀|⊘|∅|au[gm]|alt|sus|dom|-|add|no|omit|[Mm]aj?|M|[#b♯♭+-]|\d+|\(|\)|\/)*(?:[A-G][#b♯♭]?)?(?:\(?drop\d\)?)?(?=\n|\s|$)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This regular expression is for separate and recognize musical chords | |
# when mixed with lyrics. | |
# Start Limit | |
\b | |
( | |
# Fundamental | |
(?:[A-G]|vii|VII|vi|VI|v|V|iv|IV|iii|III|ii|II|i|I)[#b♯♭]? | |
# Term between fundamental and bass | |
(?:m(?:i(?:n(?:or)?)?)?|\+|½?dim|º|°|⁰|◦|⸰|○|⚬|∆|Δ|△|Ø|ø|⌀|⊘|∅| | |
au[gm]|alt|sus|dom|-|add|no|omit|[Mm]aj?|M|[#b♯♭+-]|\d+|\(|\)|\/)* | |
# Bass | |
(?:[A-G][#b♯♭]?)? | |
# Drop | |
(?:\(?drop\d\)?)? | |
# End Limite | |
(?=\n|\s|$) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This regular expression compared to the other file of other gist, is not strict, it allows strange combinations.
http://rubular.com/r/TU5Pjw9xzkUJYn