Reputation: 327
Here is the string
a = "http://www.peoples.net/mcfnet/viewtopic.php?f=143&t=4898958&sid=2110d616dbad926"
Now, we need to split this string into two and need a single string.
expected output is:
b = "http://www.peoples.net/mcfnet/viewtopic.php?f=143&t=4898958&"
Upvotes: 2
Views: 1576
Reputation: 1172
Try using the substring function
I think with the substring-before-match you can do what you want, or try take a look on the other substring's function.Check this link.
Upvotes: 1
Reputation: 243479
You want to get all of the original string except the last query-string parameter.
Here is a single XPath 2.0 expression to produce this string from the original, which is defined in a variable named $vA
:
codepoints-to-string
(
reverse
(string-to-codepoints
(substring-after
(codepoints-to-string
(reverse(string-to-codepoints($vA))
),
'&'
)
)
)
)
Explanation:
We turn the string into a sequence of characters using string-to-codepoints()
and reverse this sequence using reverse()
. Then we turn the reversed sequence of characters back to a string using `codepoints-to-string.
From the reversed string (produced by 1. above) we get the substring after the first &
. We do this using substring-after()
This is our result, but reversed -- we reverse it back to normal, using exactly the same logic as in step 1. above.
Upvotes: 0