webdad3
webdad3

Reputation: 9080

optional substring character

I'm using XSLT 1.0

I have a node that sometimes has a ~ in it:

<node id="123~001"/>

And sometimes it doesn't:

<node id="123"/>

I'm wondering if the substring-before command allows for optional characters? If it doesn't what is the best way to check to see if the ~ exists or not?

Upvotes: 0

Views: 90

Answers (1)

BeniBela
BeniBela

Reputation: 16927

Just add an -, then there always is one:

substring-before(concat(@id, "-"), "-")

Upvotes: 1

Related Questions