regex url for ticket ID
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

i have some jira urls like this

https://domain.com/secure/RapidBoard.jspa?rapidView=41&projectKey=AU&modal=detail&selectedIssue=AU-437

https://domain.com/browse/AU-437

https://domain.comt/secure/RapidBoard.jspa?rapidView=41&view=planning&selectedIssue=AU-292

and we need to be able to parse out of the url the ticket ID. From the examples above and clicking around all the ways to see things in jira that we are looking for something that fits the following pattern

-has a hyphen in it (this is probably the key in the expression)
-alpha before the hyphen (this is between 2 and 8 characters ALWAYS)
-numeric after the hyphen (will ALWAYS be numeric)

the output of the regex should be two parts:

1- the ID by itself, for example AU-437

2- a reformatted link to the ticket - we can use this template https://domain.com/browse/{ticketID_here}

if you dont mind please use this for submitting solutions https://regex101.com/ it makes things a lot easier to test and verify. Thanks!

awarded to B44ken
Tags
regex

Crowdsource coding tasks.

5 Solutions

Winning solution

This is the Regex part: https://regex101.com/r/ezgIl6/3. How do you want the reformatting part done?
I did it in Python, I can do other languages if you're working in something else (probably): https://repl.it/@Bak0n/JIRA-Reformatter

Can the script append the parsed ID to the template stub url front? "https://domain.com/browse/"
Qdev 17 days ago
I updated my answer with a repl.it link, because Bountify's Markdown parser seems to not like comments and thinks they're headings.
B44ken 17 days ago
Python works!
Qdev 17 days ago

n
\n@media print {
\n html, body {
\n overflow: hidden;
\n }
\n}
\n<\/code><\/p>\n

View Timeline