Created
April 6, 2018 08:30
-
-
Save caub/7284d41ff8bc9bc607514923b3ab9b24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ## like \1 but named: | |
/(?<fruit>apple|fig)==\k<fruit>/u.test('fig==fig') | |
// true | |
// ## named group captures: | |
'we can'.replace(/(?<subject>\w+) (?<verb>\w+)/u, '$<subject>...$<verb>') | |
//"we...can" | |
'yes, we can'.replace(/(?<w>\w+)[,\s]+/gu, '$<w>...') | |
// "yes...we...can" | |
'2018-03-28'.match(/(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})/u).groups | |
// {y: "2018", m: "03", d: "28"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment