query-72c65f01af02d1c2e2aba01dc59187c1
Conversion from format1 to format2 and format3 SELECT ?format1 ?format2 ?format3 ?num1 ?num2 ?num3 ?num4 { VALUES ?format1 { "91-2-2008-3" "398-1-1100-1" "529-102-11-1" "148-402-27-1" }
BIND (REPLACE(?format1, "(\d+)-(\d+)-(\d+)-(\d+)", "$1") AS ?num1) BIND (REPLACE(?format1, "(\d+)-(\d+)-(\d+)-(\d+)", "$2") AS ?num2) BIND (REPLACE(?format1, "(\d+)-(\d+)-(\d+)-(\d+)", "$3") AS ?num3) BIND (REPLACE(?format1, "(\d+)-(\d+)-(\d+)-(\d+)", "$4") AS ?num4)
BIND (CONCAT( SUBSTR(CONCAT("00", ?num1), STRLEN(?num1), 3), "-", SUBSTR(CONCAT("00", ?num2), STRLEN(?num2), 3), "-", SUBSTR(CONCAT("000", ?num3), STRLEN(?num3), 4), "-", SUBSTR(CONCAT("000", ?num4), STRLEN(?num4), 4)) AS ?format2)
BIND (CONCAT( SUBSTR(CONCAT("00", ?num1), STRLEN(?num1), 3), SUBSTR(CONCAT("00", ?num2), STRLEN(?num2), 3), SUBSTR(CONCAT("000", ?num3), STRLEN(?num3), 4), SUBSTR(CONCAT("000", ?num4), STRLEN(?num4), 4)) AS ?format3) }
Use at
- https://query.wikidata.org/sparql
# Conversion from format1 to format2 and format3
SELECT ?format1 ?format2 ?format3 ?num1 ?num2 ?num3 ?num4
{
VALUES ?format1 { "91-2-2008-3" "398-1-1100-1" "529-102-11-1" "148-402-27-1" }
BIND (REPLACE(?format1, "(\\d+)-(\\d+)-(\\d+)-(\\d+)", "$1") AS ?num1)
BIND (REPLACE(?format1, "(\\d+)-(\\d+)-(\\d+)-(\\d+)", "$2") AS ?num2)
BIND (REPLACE(?format1, "(\\d+)-(\\d+)-(\\d+)-(\\d+)", "$3") AS ?num3)
BIND (REPLACE(?format1, "(\\d+)-(\\d+)-(\\d+)-(\\d+)", "$4") AS ?num4)
BIND (CONCAT(
SUBSTR(CONCAT("00", ?num1), STRLEN(?num1), 3), "-",
SUBSTR(CONCAT("00", ?num2), STRLEN(?num2), 3), "-",
SUBSTR(CONCAT("000", ?num3), STRLEN(?num3), 4), "-",
SUBSTR(CONCAT("000", ?num4), STRLEN(?num4), 4)) AS ?format2)
BIND (CONCAT(
SUBSTR(CONCAT("00", ?num1), STRLEN(?num1), 3),
SUBSTR(CONCAT("00", ?num2), STRLEN(?num2), 3),
SUBSTR(CONCAT("000", ?num3), STRLEN(?num3), 4),
SUBSTR(CONCAT("000", ?num4), STRLEN(?num4), 4)) AS ?format3)
}