F
F
froja2021-06-19 16:19:54
XPath
froja, 2021-06-19 16:19:54

How to write an XPath expression to match a string by parameters: 13 characters, and all of them are numbers?

I need to write an XPath to find an element that has 13 characters and all of them are numbers. For example,<p>319237500423184</p>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2021-06-22
@alekciy

If there is a desire to write a regular expression in the framework of XPath, then most likely the problem statement is initially erroneous. In the second version of the specification, the matches function was added, but it can work differently in different implementations. In general, there should be something in the spirit:
//*[matches(., '\d{12}')]
but in this form it will not solve the problem (all ancestors from this element to the root of the document will fall). Those. the short answer is that there is no solution in XPath if you set the original problem in this way. It is better to write an example of markup from which you need to pull data and by what criteria.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question