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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:45:05+00:00 2026-05-21T14:45:05+00:00

<p <%=foo1%> <%=foo2%> > <h3><%=bar1%></h3> <h4><%=bar2%></h4> </p> I am looking for a regular experssion

  • 0
<p <%=foo1%> <%=foo2%> >

   <h3><%=bar1%></h3>

   <h4><%=bar2%></h4>

</p>

I am looking for a regular experssion the result of which should be foo1 and foo2 because those are the values declared as attributes. bar1 and bar2 should not be captured because they are not declared as attributes.

I am using ruby 1.8.7.

  • 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-21T14:45:06+00:00Added an answer on May 21, 2026 at 2:45 pm

    This is a case where I think you’re better off doing two passes. First, extract all the <% %> data values that are attributes inside tags. Then, go through and extract off the <% and %>.

    For example:

     <[^>]*?((?:<%=[^%]*%>\s*)+)[^<]*>
    

    Gives you:

       <%=foo1%> <%=foo2%>
    

    Then, a simple

    <%=(.*?)%>
    

    on the output from the first regex, gives you foo1, foo2, etc. I’ve been trying to construct a combined one, but the only way I can see to do that is to use a look-behind operation. I don’t think that’s supported in Ruby, and regardless since the look-behind would have to match at the same point multiple times, I believe most engines would kick it out.

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

Sidebar

Related Questions

<table> <tr> <td>foo1</td> <td>bar1</td> <td><input type=button id=button1 onClick=get(this);></td> </tr> <tr> <td>foo2</td> <td>bar2</td> <td><input type=button
with the XML structure below: <root foo1=bar1 foo2=bar2 foo3=bar3> <foo1 foo1=bar1 /> <data> <foo1>bar1</foo1>
For example: SELECT a, IF (c = DECODE(b, foo1, bar1, foo2, bar2) THEN c
For example: root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3
I have a structure like this: {:foo => ['foo1', 'foo2'], :bar => ['bar1']} Which
I have a text file which looks like this: blah blah foo1 bar1 foo1
How to insert into a table the result from a query like: ;with foo(foo1,foo2)
> a = %w[foo1 foo2 foo3 foo4 foo5 foo6] => [foo1, foo2, foo3, foo4,
I have a file that contains: foo1 = 1 foo2 = 2 foo3 =
I have a set of column names in a table - e.g. foo1, foo2,

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.