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

  • Home
  • SEARCH
  • 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 75491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:31:28+00:00 2026-05-10T20:31:28+00:00

I have a RegEx that is working for me but I don’t know WHY

  • 0

I have a RegEx that is working for me but I don’t know WHY it is working for me. I’ll explain.

RegEx: \s*<in.*='(<?.*?>)'\s*/>\s* 

Text it finds (it finds the white-space before and after the input tag):

<td class='style9'>       <input name='guarantor4' id='guarantor4' size='50' type='text' tabindex='10' value='<?php echo $data[guarantor4]; ?>'  />    </td> </tr> 

The part I don’t understand:

<in.*=' <--- As I understand it, this should only find up to the first =' as in it should only find <input name='  It actually finds: <input name='guarantor4' id='guarantor4' size='50' type='text' tabindex='10' value=' which happened to be what I was trying to do. 

What am I not understanding about this RegEx?

  • 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. 2026-05-10T20:31:29+00:00Added an answer on May 10, 2026 at 8:31 pm

    You appear to be using ‘greedy’ matching.

    Greedy matching says ‘eat as much as possible to make this work’

    try with

    <in[^=]*=   

    for starters, that will stop it matching the ‘=’ as part of ‘.*’

    but in future, you might want to read up on the

    .*?   

    and

    .+? 

    notation, which stops at the first possible condtion that matches instead of the last.

    The use of ‘non-greedy’ syntax would be better if you were trying to only stop when you saw TWO characters,

    ie:

    <in.*?=id 

    which would stop on the first ‘=id’ regardless of whether or not there are ‘=’ in between.

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

Sidebar

Related Questions

I have a long RegEx that is working, but I have a section at
I have a function that finds a regex thingy, then replaces with php code.
I have a regex in mysql and wanna to inverse it. but don't wanna
I have the following regex that isn't working. I want to match the string
I have a regex that I thought was working correctly until now. I need
I have this regex that is supposed to match 1='aa' or 1=aa or 1=aa,
I have a regex expression that I'm doing a split against another string and
I have been trying to write a regex that will remove whitespace following a
Let's say I have two strings like this: XABY XBAY A simple regex that
I have heard that MSBuild 4.0 has increased Regex parsing support. However, I am

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.