Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6758395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:46:55+00:00 2026-05-26T13:46:55+00:00

I want to find a table cell that contains the link (\d{0,3} )?pieces .

  • 0

I want to find a table cell that contains the link (\d{0,3} )?pieces.

How would I need to write this xpath?

Can I simply insert the xpath directly into the Capybara search? Or do I need to do something special to indicate it is a regex? Or can I not do it at all?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:46:56+00:00Added an answer on May 26, 2026 at 1:46 pm

    Xpath 1.0

    XPath 1.0 does not include regular expression support. You should be able to achieve the desired match with the following expression:

    //td/a['pieces'=substring(@href, string-length(@href) - 
                                     string-length('pieces') + 1) and 
           'pieces'=translate(@href, '0123456789', '') and 
            string-length(@href) > 5 and 
            string-length(@href) < 10]
    

    The first test in the predicate checks that the string ends with pieces. The second test ensures that the entire string equals pieces when all of the digits are removed (i.e. there are no other characters). The final two tests ensure that the entire length of the string is between 6 and 9, which is the length of pieces plus zero to three digits.

    Test it on the following document:

    <table>
        <tr>
            <td><a href="444pieces">test0</a></td>
            <td>no match</td>
            <td>no match</td>
            <td><a href="123pieces">test1</a></td>
            <td><a href="12pieces">test2</a></td>
            <td><a href="1232pieces">no match</a></td>
            <td><a href="pieces">test3</a></td>
        </tr>
    </table>
    

    It should match only the test0, test1, test2, and test3 links.

    (Note: The expression may be further complicated by the possibility of other characters preceding the portion you’re attempting to match.)

    XPath 2.0

    Achieving this in XPath 2.0 is trivial with the matches function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find which tables are related to a specific table. I can
HTML: <table> <tr> <td> <a href=#>link</a> </td> </tr> </table> I want to: FIND 'link'
HTML: <table> <tr> <td> <a href=# class=nav>link</a> <td> </tr> </table> I want to: FIND
I have a custom table cell with a UILabel in. What I want can
I want to find all foreign keys in a table, and for each foreign
I want to find the sum and count of specific values in my table.
I want to find the specific string in specific column of data table so
I have a table like: id number year I want to find holes, or
I previously created a MySQL table and now I want to find out what
I have the following table in my database. Now what I want to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.