Information technology — Guidance for the use of database language SQL — Part 1: XQuery regular expressions

Technologies de l'information — Recommandations pour l'utilisation du langage de base de données SQL — Partie 1: Expressions régulières de XQuery en SQL

General Information

Status
Published
Publication Date
30-Aug-2021
Current Stage
6060 - International Standard published
Start Date
31-Aug-2021
Due Date
11-Feb-2024
Completion Date
31-Aug-2021
Ref Project

Relations

Buy Standard

Standard
ISO/IEC 19075-1:2021 - Information technology — Guidance for the use of database language SQL — Part 1: XQuery regular expressions Released:8/31/2021
English language
25 pages
sale 15% off
Preview
sale 15% off
Preview
Standard
ISO/IEC 19075-1:2021 - Information technology -- Guidance for the use of database language SQL
English language
25 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (Sample)


INTERNATIONAL ISO/IEC
STANDARD 19075-1
First edition
2021-08
Information technology — Guidance
for the use of database language
SQL —
Part 1:
XQuery regular expressions
Technologies de l'information — Recommandations pour l'utilisation
du langage de base de données SQL —
Partie 1: Expressions régulières de XQuery en SQL
Reference number
©
ISO/IEC 2021
© ISO/IEC 2021
All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may
be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting
on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address
below or ISO’s member body in the country of the requester.
ISO copyright office
CP 401 • Ch. de Blandonnet 8
CH-1214 Vernier, Geneva
Phone: +41 22 749 01 11
Email: copyright@iso.org
Website: www.iso.org
Published in Switzerland
ii © ISO/IEC 2021 – All rights reserved

Contents Page
Foreword.v
Introduction.vii
1 Scope.1
2 Normativereferences.2
3 Termsanddefinitions.3
4 XQueryregularexpressions.4
4.1 ContextofXQueryregularexpressions.4
4.2 IntroductiontoXQueryregularexpressions.4
4.3 Matchingaspecificcharacter.4
4.4 Metacharactersandescapesequences.5
4.5 Dot.6
4.6 Anchors.7
4.7 Lineterminators.7
4.8 Bracket expressions.8
4.8.1 Introductiontobracketexpressions.8
4.8.2 Listing characters.8
4.8.3 Matchingarange.9
4.8.4 Negation.9
4.8.5 Characterclasssubtraction.9
4.9 Alternation.9
4.10 Quantifiers.10
4.11 Locatingamatch.11
4.12 Captureandback-reference.12
4.13 Precedence.13
4.14 Modes.13
5 Operatorsusingregularexpressions.15
5.1 Introductiontooperatorsusingregularexpressions.15
5.2 LIKE_REGEX.15
5.3 OCCURRENCES_REGEX.16
5.4 POSITION_REGEX.17
5.5 SUBSTRING_REGEX.19
5.6 TRANSLATE_REGEX.20
Bibliography.23
Index.24
© ISO/IEC 2021 – All rights reserved iii

Tables
Table Page
1 Match priorities.11
iv © ISO/IEC 2021 – All rights reserved

Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical
Commission) form the specialized system for worldwide standardization. National bodies that are
members of ISO or IEC participate in the development of International Standards through technical
committees established by the respective organization to deal with particular fields of technical activity.
ISO and IEC technical committees collaborate in fields of mutual interest. Other international
organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the
work.
The procedures used to develop this document and those intended for its further maintenance are
described in the ISO/IEC Directives, Part 1. In particular, the different approval criteria needed for the
different types of document should be noted. This document was drafted in accordance with the editorial
rules of the ISO/IEC Directives, Part 2 (see www.iso.org/directives or
www.iec.ch/members_experts/refdocs).
Attention is drawn to the possibility that some of the elements of this document may be the subject of
patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. Details
of any patent rights identified during the development of the document will be in the Introduction and/or
on the ISO list of patent declarations received (see www.iso.org/patents) or the IEC list of patent
declarations received (see patents.iec.ch).
Any trade name used in this document is information given for the convenience of users and does not
constitute an endorsement.
For an explanation of the voluntary nature of standards, the meaning of ISO specific terms and
expressions related to conformity assessment, as well as information about ISO's adherence to the World
Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT) see
www.iso.org/iso/foreword.html. In the IEC, see www.iec.ch/understanding-standards.
This document was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology,
Subcommittee SC 32, Data management and interchange.
This first edition of ISO/IEC 19075-1 cancels and replaces ISO/IEC TR 19075-1:2011.
This document is intended to be used in conjunction with the following editions of the parts of the
ISO/IEC 9075 series:
— ISO/IEC 9075-1, sixth edition or later;
— ISO/IEC 9075-2, sixth edition or later;
— ISO/IEC 9075-3, sixth edition or later;
— ISO/IEC 9075-4, seventh edition or later;
— ISO/IEC 9075-9, fifth edition or later;
— ISO/IEC 9075-10, fifth edition or later;
— ISO/IEC 9075-11, fifth edition or later;
— ISO/IEC 9075-13, fifth edition or later;
v
© ISO/IEC 2021 – All rights reserved

— ISO/IEC 9075-14, sixth edition or later;
— ISO/IEC 9075-15, second edition or later;
— ISO/IEC 9075-16, first edition or later.
A list of all parts in the ISO/IEC 19075 series can be found on the ISO and IEC websites.
Any feedback or questions on this document should be directed to the user’s national standards body. A
complete listing of these bodies can be found at www.iso.org/members.html and www.iec.ch/national-
committees.
vi
Introduction
Theorganizationofthisdocumentisasfollows:
1) Clause1,“Scope”,specifiesthescopeofthisdocument.
2) Clause2,“Normativereferences”,identifiesadditionalstandardsthat,throughreferenceinthis
document,constituteprovisionsofthisdocument.
3) Clause3,“Termsanddefinitions”,definesthetermsanddefinitionsusedinthisdocument.
4) Clause4,“XQueryregularexpressions”,explainshowXQueryregularexpressionsareformed.
5) Clause5,“Operatorsusingregularexpressions”,explainshowtheSQLoperatorsuseregular
expressions.
© ISO/IEC 2021 – All rights reserved vii

INTERNATIONAL STANDARD ISO/IEC 19075-1:2021(E)
Informationtechnology—GuidancefortheuseofdatabaselanguageSQL—
Part1:
XQueryregularexpressions
1 Scope
ThisdocumentdescribestheregularexpressionsupportinSQL(ISO/IEC9075-2)adoptedfromthe
regularexpressionsyntaxofXQueryandXPathFunctionsandOperators3.1,whichisderivedfromPerl.
Thisdocumentdiscussesfiveoperatorsusingthisregularexpressionsyntax:
— LIKE_REGEXpredicate,todeterminetheexistenceofamatchtoaregularexpression.
— OCCURRENCES_REGEXnumericfunction,todeterminethenumberofmatchestoaregularexpression.
— POSITION_REGEXfunction,todeterminethepositionofamatch.
— SUBSTRING_REGEXfunction,toextractasubstringmatchingaregularexpression.
— TRANSLATE_REGEXfunction,toperformreplacementsusingaregularexpression.
© ISO/IEC 2021 – All rights reserved 1

2 Normative references
The following documents are referred to in the text in such a way that some or all of their content consti-
tutes requirements of this document. For dated references, only the edition cited applies. For undated
references, the latest edition of the referenced document (including any amendments) applies.
ISO/IEC9075-1,Informationtechnology—Databaselanguages—SQL—Part1:Framework
(SQL/Framework)
ISO/IEC9075-2,Informationtechnology—Databaselanguages—SQL—Part2:Foundation
(SQL/Foundation)
ISO/IEC9075-14,Informationtechnology—Databaselanguages—SQL—Part14:XML-Related
Specifications(SQL/XML)
Bray,Timetal.ExtensibleMarkupLanguage(XML)Version1.0,W3CRecommendation[online].Fifth
Edition.Cambridge,Massachusetts,USA:W3C,26November2008.Availableat
http://www.w3.org/TR/xml
Bray,Timetal.ExtensibleMarkupLanguage(XML)Version1.1,W3CRecommendation[online].Second
Edition.Cambridge,Massachusetts,USA:W3C,16August2006.Availableat
http://www.w3.org/TR/xml11
Biron,PaulV.;Malhotra,Ashok.XMLSchemaPart2:Datatypes,W3CRecommendation[online].Second
Edition.Cambridge,Massachusetts,USA:W3C,28October2004.Availableat
http://www.w3.org/TR/xmlschema-2/
Malhotra,Ashoketal.XQueryandXPathFunctionsandOperators3,1,W3CRecommendation[online].
Cambridge,Massachusetts,USA:W3C,21March2017.Availableathttp://www.w3.org/TR/-
xpath-functions/
TheUnicodeConsortium.UnicodeRegularExpressions[online].21.MountainView,California,USA:
TheUnicodeConsortium,2020-06-17.Availableathttp://www.unicode.org/reports/tr18/-
tr18-21.html
2 © ISO/IEC 2021 – All rights reserved

3 Termsanddefinitions
Forthepurposesofthisdocument,thetermsanddefinitionsgiveninISO/IEC9075-1apply.
ISOandIECmaintainterminologicaldatabasesforuseinstandardizationatthefollowingaddresses:
— IECElectropedia:availableathttp://www.electropedia.org/
— ISOOnlinebrowsingplatform:availableathttp://www.iso.org/obp
© ISO/IEC 2021 – All rights reserved 3

4 XQueryregularexpressions
4.1 ContextofXQueryregularexpressions
TherequirementsforthematerialdiscussedinthisdocumentshallbeasspecifiedinISO/IEC9075-2,
ISO/IEC9075-14,XML1.0,XML1.1,XMLSchemaPart2:Datatypes,XQueryandXPathFunctionsand
Operators3.1,andUnicodeTechnicalStandard#18.
4.2 IntroductiontoXQueryregularexpressions
ThisdocumentexplainsthemannerinwhichXQueryregularexpressionsareusedbydatabaselanguage
SQLinISO/IEC9075-2andinISO/IEC9075-14.BothISO/IEC9075-2andISO/IEC9075-14specify
requirementsforthematerialdiscussedinthisdocument.
XQueryregularexpressionsyntaxisspecifiedinXQueryandXPathFunctionsandOperators3.1,section
5.6.1,“Regularexpressionsyntax”.ThispaperreferencestheXQueryspecification,withtwosmallmodi-
fications(requiredsincecharacterstringsinanRDBMSarenotnecessarilynormalizedaccordingtoXML
conventions).Thefollowingsubsectionsprovideanoverviewofthissyntax.
TheXQueryregularexpressionsyntaxisitselfamodificationofanotherregularexpressionsyntaxfound
inXMLSchemaPart2:Datatypes.
ThissectionpresentsanoverviewofthecapabilitiesofXQueryregularexpressionsyntax.Intheprocess,
thissectionwillillustratesomeoftheSQLoperators.TheSQLoperatorsthemselvesarepresentedin
Clause5,“Operatorsusingregularexpressions”.
ThefollowingdiscussiondoesnotcovereveryaspectofXQueryregularexpressions;forthis,XQuery
andXPathFunctionsandOperators3.1isthereference(thoughhardlyatutorial;avarietyofpopular
workscontaindetailedtreatmentsofregularexpressions).
4.3 Matchingaspecificcharacter
Perhapsthemostelementarypatternmatchingrequirementistheabilitytomatchasinglecharacteror
string.Formostcharacters,thisisdonebysimplywritingthecharacterintheregularexpression.For
example,supposeanapplicationneedstoknowifastringScontainstheletters“xyz”.Thiscouldbedone
withthefollowingpredicate:
S LIKE_REGEX 'xyz'
NotethattheSQLLIKEpredicatewouldrequireanexactmatchfor“xyz”.However,theconventionwith
regularexpressionsisthatSneedonlycontainasubstringthatis“xyz”.Forexample,allofthefollowing
valuesofSwouldyieldTruefortheimmediatelyprecedingpredicate:
xyz
abcxyz123
1 xyz 2 xyz 3 xyz
4 © ISO/IEC 2021– All rights reserved

4.3 Matching a specific character
Notethatinthelastexample,thereareactuallythreeoccurrencesoftheregularexpression“xyz”within
thetestedvalue.Theusermaywishtoknowthenumberofoccurrencesofamatch.Thiscanbedone
withOCCURRENCES_REGEX.Forexample:
OCCURRENCES_REGEX ('xyz' IN '1 xyz 2 xyz 3 xyz') = 3
Theusermightalsowishtoknowthepositionofaspecificmatch.ThiscanbedoneusingPOSITION_REGEX.
Forexample,tolearnthestartingcharacterpositionofthesecondoccurrence,
POSITION_REGEX ( 'xyz' IN '1 xyz 2 xyz 3 xyz' OCCURRENCE 2 ) = 9
Itisalsopossibletoaskforthecharacterpositionofthefirstcharacterafterthematch.Forexample:
POSITION_REGEX ( AFTER 'xyz' IN '1 xyz 2 xyz 3 xyz' OCCURRENCE 2 ) = 12
IfAFTERisusedandthelastcharacterofthesubjectstringisconsumed,thentheresultisthelengthof
thestringplus1(one):
POSITION_REGEX ( AFTER 'xyz' IN 'xyz' ) = 4
4.4 Metacharactersandescapesequences
Asmentioned,mostcharacterscanbematchedbysimplywritingthecharacterintheregularexpression.
However,certaincharactersarereservedasmetacharacters.Thecompletelistofmetacharactersis:
. \ ? * + { } ( ) | [ ] ^ $
Theuseofeachoftheseme
...


INTERNATIONAL ISO/IEC
STANDARD 19075-1
First edition
2021-08
Information technology — Guidance
for the use of database language
SQL —
Part 1:
XQuery regular expressions
Technologies de l'information — Recommandations pour l'utilisation
du langage de base de données SQL —
Partie 1: Expressions régulières de XQuery en SQL
Reference number
©
ISO/IEC 2021
© ISO/IEC 2021
All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may
be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting
on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address
below or ISO’s member body in the country of the requester.
ISO copyright office
CP 401 • Ch. de Blandonnet 8
CH-1214 Vernier, Geneva
Phone: +41 22 749 01 11
Email: copyright@iso.org
Website: www.iso.org
Published in Switzerland
ii © ISO/IEC 2021 – All rights reserved

Contents Page
Foreword.v
Introduction.vii
1 Scope.1
2 Normativereferences.2
3 Termsanddefinitions.3
4 XQueryregularexpressions.4
4.1 ContextofXQueryregularexpressions.4
4.2 IntroductiontoXQueryregularexpressions.4
4.3 Matchingaspecificcharacter.4
4.4 Metacharactersandescapesequences.5
4.5 Dot.6
4.6 Anchors.7
4.7 Lineterminators.7
4.8 Bracket expressions.8
4.8.1 Introductiontobracketexpressions.8
4.8.2 Listing characters.8
4.8.3 Matchingarange.9
4.8.4 Negation.9
4.8.5 Characterclasssubtraction.9
4.9 Alternation.9
4.10 Quantifiers.10
4.11 Locatingamatch.11
4.12 Captureandback-reference.12
4.13 Precedence.13
4.14 Modes.13
5 Operatorsusingregularexpressions.15
5.1 Introductiontooperatorsusingregularexpressions.15
5.2 LIKE_REGEX.15
5.3 OCCURRENCES_REGEX.16
5.4 POSITION_REGEX.17
5.5 SUBSTRING_REGEX.19
5.6 TRANSLATE_REGEX.20
Bibliography.23
Index.24
© ISO/IEC 2021 – All rights reserved iii

Tables
Table Page
1 Match priorities.11
iv © ISO/IEC 2021 – All rights reserved

Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical
Commission) form the specialized system for worldwide standardization. National bodies that are
members of ISO or IEC participate in the development of International Standards through technical
committees established by the respective organization to deal with particular fields of technical activity.
ISO and IEC technical committees collaborate in fields of mutual interest. Other international
organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the
work.
The procedures used to develop this document and those intended for its further maintenance are
described in the ISO/IEC Directives, Part 1. In particular, the different approval criteria needed for the
different types of document should be noted. This document was drafted in accordance with the editorial
rules of the ISO/IEC Directives, Part 2 (see www.iso.org/directives or
www.iec.ch/members_experts/refdocs).
Attention is drawn to the possibility that some of the elements of this document may be the subject of
patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. Details
of any patent rights identified during the development of the document will be in the Introduction and/or
on the ISO list of patent declarations received (see www.iso.org/patents) or the IEC list of patent
declarations received (see patents.iec.ch).
Any trade name used in this document is information given for the convenience of users and does not
constitute an endorsement.
For an explanation of the voluntary nature of standards, the meaning of ISO specific terms and
expressions related to conformity assessment, as well as information about ISO's adherence to the World
Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT) see
www.iso.org/iso/foreword.html. In the IEC, see www.iec.ch/understanding-standards.
This document was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology,
Subcommittee SC 32, Data management and interchange.
This first edition of ISO/IEC 19075-1 cancels and replaces ISO/IEC TR 19075-1:2011.
This document is intended to be used in conjunction with the following editions of the parts of the
ISO/IEC 9075 series:
— ISO/IEC 9075-1, sixth edition or later;
— ISO/IEC 9075-2, sixth edition or later;
— ISO/IEC 9075-3, sixth edition or later;
— ISO/IEC 9075-4, seventh edition or later;
— ISO/IEC 9075-9, fifth edition or later;
— ISO/IEC 9075-10, fifth edition or later;
— ISO/IEC 9075-11, fifth edition or later;
— ISO/IEC 9075-13, fifth edition or later;
v
© ISO/IEC 2021 – All rights reserved

— ISO/IEC 9075-14, sixth edition or later;
— ISO/IEC 9075-15, second edition or later;
— ISO/IEC 9075-16, first edition or later.
A list of all parts in the ISO/IEC 19075 series can be found on the ISO and IEC websites.
Any feedback or questions on this document should be directed to the user’s national standards body. A
complete listing of these bodies can be found at www.iso.org/members.html and www.iec.ch/national-
committees.
vi
Introduction
Theorganizationofthisdocumentisasfollows:
1) Clause1,“Scope”,specifiesthescopeofthisdocument.
2) Clause2,“Normativereferences”,identifiesadditionalstandardsthat,throughreferenceinthis
document,constituteprovisionsofthisdocument.
3) Clause3,“Termsanddefinitions”,definesthetermsanddefinitionsusedinthisdocument.
4) Clause4,“XQueryregularexpressions”,explainshowXQueryregularexpressionsareformed.
5) Clause5,“Operatorsusingregularexpressions”,explainshowtheSQLoperatorsuseregular
expressions.
© ISO/IEC 2021 – All rights reserved vii

INTERNATIONAL STANDARD ISO/IEC 19075-1:2021(E)
Informationtechnology—GuidancefortheuseofdatabaselanguageSQL—
Part1:
XQueryregularexpressions
1 Scope
ThisdocumentdescribestheregularexpressionsupportinSQL(ISO/IEC9075-2)adoptedfromthe
regularexpressionsyntaxofXQueryandXPathFunctionsandOperators3.1,whichisderivedfromPerl.
Thisdocumentdiscussesfiveoperatorsusingthisregularexpressionsyntax:
— LIKE_REGEXpredicate,todeterminetheexistenceofamatchtoaregularexpression.
— OCCURRENCES_REGEXnumericfunction,todeterminethenumberofmatchestoaregularexpression.
— POSITION_REGEXfunction,todeterminethepositionofamatch.
— SUBSTRING_REGEXfunction,toextractasubstringmatchingaregularexpression.
— TRANSLATE_REGEXfunction,toperformreplacementsusingaregularexpression.
© ISO/IEC 2021 – All rights reserved 1

2 Normative references
The following documents are referred to in the text in such a way that some or all of their content consti-
tutes requirements of this document. For dated references, only the edition cited applies. For undated
references, the latest edition of the referenced document (including any amendments) applies.
ISO/IEC9075-1,Informationtechnology—Databaselanguages—SQL—Part1:Framework
(SQL/Framework)
ISO/IEC9075-2,Informationtechnology—Databaselanguages—SQL—Part2:Foundation
(SQL/Foundation)
ISO/IEC9075-14,Informationtechnology—Databaselanguages—SQL—Part14:XML-Related
Specifications(SQL/XML)
Bray,Timetal.ExtensibleMarkupLanguage(XML)Version1.0,W3CRecommendation[online].Fifth
Edition.Cambridge,Massachusetts,USA:W3C,26November2008.Availableat
http://www.w3.org/TR/xml
Bray,Timetal.ExtensibleMarkupLanguage(XML)Version1.1,W3CRecommendation[online].Second
Edition.Cambridge,Massachusetts,USA:W3C,16August2006.Availableat
http://www.w3.org/TR/xml11
Biron,PaulV.;Malhotra,Ashok.XMLSchemaPart2:Datatypes,W3CRecommendation[online].Second
Edition.Cambridge,Massachusetts,USA:W3C,28October2004.Availableat
http://www.w3.org/TR/xmlschema-2/
Malhotra,Ashoketal.XQueryandXPathFunctionsandOperators3,1,W3CRecommendation[online].
Cambridge,Massachusetts,USA:W3C,21March2017.Availableathttp://www.w3.org/TR/-
xpath-functions/
TheUnicodeConsortium.UnicodeRegularExpressions[online].21.MountainView,California,USA:
TheUnicodeConsortium,2020-06-17.Availableathttp://www.unicode.org/reports/tr18/-
tr18-21.html
2 © ISO/IEC 2021 – All rights reserved

3 Termsanddefinitions
Forthepurposesofthisdocument,thetermsanddefinitionsgiveninISO/IEC9075-1apply.
ISOandIECmaintainterminologicaldatabasesforuseinstandardizationatthefollowingaddresses:
— IECElectropedia:availableathttp://www.electropedia.org/
— ISOOnlinebrowsingplatform:availableathttp://www.iso.org/obp
© ISO/IEC 2021 – All rights reserved 3

4 XQueryregularexpressions
4.1 ContextofXQueryregularexpressions
TherequirementsforthematerialdiscussedinthisdocumentshallbeasspecifiedinISO/IEC9075-2,
ISO/IEC9075-14,XML1.0,XML1.1,XMLSchemaPart2:Datatypes,XQueryandXPathFunctionsand
Operators3.1,andUnicodeTechnicalStandard#18.
4.2 IntroductiontoXQueryregularexpressions
ThisdocumentexplainsthemannerinwhichXQueryregularexpressionsareusedbydatabaselanguage
SQLinISO/IEC9075-2andinISO/IEC9075-14.BothISO/IEC9075-2andISO/IEC9075-14specify
requirementsforthematerialdiscussedinthisdocument.
XQueryregularexpressionsyntaxisspecifiedinXQueryandXPathFunctionsandOperators3.1,section
5.6.1,“Regularexpressionsyntax”.ThispaperreferencestheXQueryspecification,withtwosmallmodi-
fications(requiredsincecharacterstringsinanRDBMSarenotnecessarilynormalizedaccordingtoXML
conventions).Thefollowingsubsectionsprovideanoverviewofthissyntax.
TheXQueryregularexpressionsyntaxisitselfamodificationofanotherregularexpressionsyntaxfound
inXMLSchemaPart2:Datatypes.
ThissectionpresentsanoverviewofthecapabilitiesofXQueryregularexpressionsyntax.Intheprocess,
thissectionwillillustratesomeoftheSQLoperators.TheSQLoperatorsthemselvesarepresentedin
Clause5,“Operatorsusingregularexpressions”.
ThefollowingdiscussiondoesnotcovereveryaspectofXQueryregularexpressions;forthis,XQuery
andXPathFunctionsandOperators3.1isthereference(thoughhardlyatutorial;avarietyofpopular
workscontaindetailedtreatmentsofregularexpressions).
4.3 Matchingaspecificcharacter
Perhapsthemostelementarypatternmatchingrequirementistheabilitytomatchasinglecharacteror
string.Formostcharacters,thisisdonebysimplywritingthecharacterintheregularexpression.For
example,supposeanapplicationneedstoknowifastringScontainstheletters“xyz”.Thiscouldbedone
withthefollowingpredicate:
S LIKE_REGEX 'xyz'
NotethattheSQLLIKEpredicatewouldrequireanexactmatchfor“xyz”.However,theconventionwith
regularexpressionsisthatSneedonlycontainasubstringthatis“xyz”.Forexample,allofthefollowing
valuesofSwouldyieldTruefortheimmediatelyprecedingpredicate:
xyz
abcxyz123
1 xyz 2 xyz 3 xyz
4 © ISO/IEC 2021– All rights reserved

4.3 Matching a specific character
Notethatinthelastexample,thereareactuallythreeoccurrencesoftheregularexpression“xyz”within
thetestedvalue.Theusermaywishtoknowthenumberofoccurrencesofamatch.Thiscanbedone
withOCCURRENCES_REGEX.Forexample:
OCCURRENCES_REGEX ('xyz' IN '1 xyz 2 xyz 3 xyz') = 3
Theusermightalsowishtoknowthepositionofaspecificmatch.ThiscanbedoneusingPOSITION_REGEX.
Forexample,tolearnthestartingcharacterpositionofthesecondoccurrence,
POSITION_REGEX ( 'xyz' IN '1 xyz 2 xyz 3 xyz' OCCURRENCE 2 ) = 9
Itisalsopossibletoaskforthecharacterpositionofthefirstcharacterafterthematch.Forexample:
POSITION_REGEX ( AFTER 'xyz' IN '1 xyz 2 xyz 3 xyz' OCCURRENCE 2 ) = 12
IfAFTERisusedandthelastcharacterofthesubjectstringisconsumed,thentheresultisthelengthof
thestringplus1(one):
POSITION_REGEX ( AFTER 'xyz' IN 'xyz' ) = 4
4.4 Metacharactersandescapesequences
Asmentioned,mostcharacterscanbematchedbysimplywritingthecharacterintheregularexpression.
However,certaincharactersarereservedasmetacharacters.Thecompletelistofmetacharactersis:
. \ ? * + { } ( ) | [ ] ^ $
Theuseofeachoftheseme
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.