query-72c65f01af02d1c2e2aba01dc59187c1

rq turtle/ttl

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

# 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)
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?format1"):::projected v6("?format2"):::projected v7("?format3"):::projected v2("?num1"):::projected v3("?num2"):::projected v4("?num3"):::projected v5("?num4"):::projected bind0[/VALUES ?format1/] bind0-->v1 bind00(["91-2-2008-3"]) bind00 --> bind0 bind01(["398-1-1100-1"]) bind01 --> bind0 bind02(["529-102-11-1"]) bind02 --> bind0 bind03(["148-402-27-1"]) bind03 --> bind0 bind1[/"replace(?format1,'(\d+)-(\d+)-(\d+)-(\d+)','$1')"/] v1 --o bind1 bind1 --as--o v2 bind2[/"replace(?format1,'(\d+)-(\d+)-(\d+)-(\d+)','$2')"/] v1 --o bind2 bind2 --as--o v3 bind3[/"replace(?format1,'(\d+)-(\d+)-(\d+)-(\d+)','$3')"/] v1 --o bind3 bind3 --as--o v4 bind4[/"replace(?format1,'(\d+)-(\d+)-(\d+)-(\d+)','$4')"/] v1 --o bind4 bind4 --as--o v5 bind5[/"concat(substring(concat('00',?num1),string-length(?num1),'3^^xsd:integer'),'-',substring(concat('00',?num2),string-length(?num2),'3^^xsd:integer'),'-',substring(concat('000',?num3),string-length(?num3),'4^^xsd:integer'),'-',substring(concat('000',?num4),string-length(?num4),'4^^xsd:integer'))"/] v2 --o bind5 v3 --o bind5 v4 --o bind5 v5 --o bind5 bind5 --as--o v6 bind6[/"concat(substring(concat('00',?num1),string-length(?num1),'3^^xsd:integer'),substring(concat('00',?num2),string-length(?num2),'3^^xsd:integer'),substring(concat('000',?num3),string-length(?num3),'4^^xsd:integer'),substring(concat('000',?num4),string-length(?num4),'4^^xsd:integer'))"/] v2 --o bind6 v3 --o bind6 v4 --o bind6 v5 --o bind6 bind6 --as--o v7