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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:02:21+00:00 2026-05-14T01:02:21+00:00

I want to extract attribute1 and attribute3 values only. I don’t understand why charset

  • 0

I want to extract attribute1 and attribute3 values only. I don’t understand why charset doesn’t seem to work in my case to “skip” any other attributes (attribute3 is not extracted as I would like):

content: {<tag attribute1="valueattribute1" attribute2="valueattribute2" attribute3="valueattribute3">
</tag>
<tag attribute2="valueattribute21" attribute1="valueattribute11" >
</tag>
}


attribute1: [{attribute1="} copy valueattribute1 to {"} thru {"}]
attribute3: [{attribute3="} copy valueattribute3 to {"} thru {"}]

spacer: charset reduce [tab newline #" "]
letter: complement spacer 
to-space: [some letter | end]

attributes-rule: [(valueattribute1: none valueattribute3: none) [attribute1 | none] any letter [attribute3 | none] (print valueattribute1 print valueattribute3)
| [attribute3 | none] any letter [attribute1 | none] (print valueattribute3 print valueattribute1
valueattribute1: none valueattribute3: none
)
| none
]

rule: [any [to {<tag } thru {<tag } attributes-rule {>} to {</tag>} thru {</tag>}] to end]

parse content rule

output is

>> parse content rule
valueattribute1
none
== true
>>
  • 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-14T01:02:21+00:00Added an answer on May 14, 2026 at 1:02 am

    Firstly you’re not using parse/all. In Rebol 2 that means that whitespace has been effectively stripped out before the parse runs. That’s not true in Rebol 3: if your parse rules are in block format (as you are doing here) then /all is implied.

    (Note: There seemed to be consensus that Rebol 3 would throw out the non-block form of parse rules, in favor of the split function for those “minimal” parse scenarios. That would get rid of /all entirely. No action has yet been taken on this, unfortunately.)

    Secondly your code has bugs, which I’m not going to spend time sorting out. (That’s mostly because I think using Rebol’s parse to process XML/HTML is a fairly silly idea :P)

    But don’t forget you have an important tool. If you use a set-word in the parse rule, then that will capture the parse position into a variable. You can then print it out and see where you’re at. Change the part of attribute-rule where you first say any letter to pos: (print pos) any letter and you’ll see this:

    >> parse/all content rule
     attribute2="valueattribute2" attribute3="valueattribute3">
    </tag>
    <tag attribute2="valueattribute21" attribute1="valueattribute11" >
    </tag>
    
    valueattribute1
    none
    == true
    

    See the leading space? Your rules right before the any letter put you at a space… and since you said any letter was ok, no letters are fine, and everything’s thrown off.

    (Note: Rebol 3 has an even better debugging tool…the word ??. When you put it in the parse block it tells you what token/rule you’re currently processing as well as the state of the input. With this tool you can more easily find out what’s going on:

    >> parse "hello world" ["hello" ?? space ?? "world"]
    space: " world"
    "world": "world"
    == true
    

    …though it’s really buggy on r3 mac intel right now.)

    Additionally, if you’re not using copy then your pattern of to X thru X is unnecessary, you can achieve that with just thru X. If you want to do a copy you can also do that with the briefer copy Y to X X or if it’s just a single symbol you could write the clearer copy Y to X skip

    In places where you see yourself writing repetitive code, remember that Rebol can go a step above by using compose etc:

    >> temp: [thru (rejoin [{attribute} num {=}]) 
              copy (to-word rejoin [{valueattribute} num]) to {"} thru {"}]
    
    >> num: 1
    >> attribute1: compose temp
    == [thru "attribute1=" copy valueattribute1 to {"} thru {"}]
    
    >> num: 2
    >> attribute2: compose temp
    == [thru "attribute2=" copy valueattribute2 to {"} thru {"}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MATLAB dataset and I want to extract the numbers only without
I want to extract tags in XML which contains attribute condition as name=var .
I want extract the path of images from a html page using PHP-preg_match_all(), the
I want to extract word after first 'from' in the following string- anti-CD24 from
I want to extract the file name 13572_BranchInformationReport_2012-06-28.zip from the following text - 1:30,/icons/def13572_BranchInformationReport_2012-06-28.zip,13572_BranchInformationReport_2012-06-28.zip,0,184296,Jun
I want to extract a substring from a line in Perl. Let me explain
I want to extract the value between the apostrophes, for example from this string:
I want to extract an elliptical region from an image (a portion of a
I want to extract information from Twitter using Python. There is a page with
i want to extract couple of tables from a web page and show them

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.