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 471711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:00:49+00:00 2026-05-13T00:00:49+00:00

I am trying to match the value of the following HTML snippet: <input name=example

  • 0

I am trying to match the value of the following HTML snippet:

<input name="example" type="hidden" value="matchTextHere" />

with the following:

x = response.match(/<input name="example" type="hidden" value="^.+$" \/>/)[0]

why is this not working? it doesn’t match ‘matchTextHere’

edit:

when i use:

x = response.match(/<input name="example" type="hidden" value="(.+)" \/>/)[0]

it matches the whole html element, and not just the value ‘matchTextHere’

  • 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-13T00:00:49+00:00Added an answer on May 13, 2026 at 12:00 am

    ^ matches start of a line and $ matches end of the line. Change ^.+$ to \w+ and it will work for values that doesn’t contain any symbols. Make it a parenthetical group to capture the value – (\w+)

    Update: to match anything between the quotes (assuming that there aren’t any quotes in the value), use [^"]+. If there are escaped quotes in the value, it is a different ballgame. .+ will work in this case, but it will be slower due to backtracking. .+ first matches upto the end of the string (because . matches even a "), then looks for a " and fails. Then it comes back one position and looks for a " and fails again – and so on until it finds the " – if there was one more attribute after value, then you will get matchTextHere" nextAttr="something as the match.

    x = response.match(/<input name="example" type="hidden" value="([^"]+)" \/>/)[1]
    

    That being said, the regex will fail if there is an extra space between any of the attribute values. Parsing html with regex is not a good idea – and if you must use regex, you can allow extra spaces using \s+

    /<input\s+name="example"\s+type="hidden"\s+value="([^"]+)"\s*\/>/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to match an expression of type field:value but not field:value I
I'm trying to match the value of query v in the following regex: http:\/\/www\.domain\.com\/videos\/video.php\?.*v=([a-z0-9-_]+)
For example, I'm trying to pick out the value Application Library from the following
I am trying to find a piece of regex to match a currency value.
I am trying to write a simple regex to match a percentage value range
I'm trying to match the following items in the string pcode : u followed
I am trying to grab numeric value(ie 105) using preg_match from html page, please
The value I'm trying to match to can either be a word OR it
I'm trying to optimize the following. The code bellow does this : If a
I have the following XPath to match authors name in an Amazon page: //div[@class='pTitle']/span[@class='small

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.