Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

newbie question

 [1/15] from: Greg::Brondo::allegiancetelecom::com at: 26-Feb-2004 12:29


Trying to wrap my mind around Rebol and now specifically the parse function. What I want to do is parse some data out of a webpage table so there is multiple rows. I'm trying to figure out how to do this in Rebol like I would in say Perl, Ruby, PHP, Python (with a global capturing regex). In perl it would look like: while( /<blah>(.*?)</blah>/g ) { print $1; } Any ideas? Greg B.

 [2/15] from: tomc:darkwing:uoregon at: 26-Feb-2004 15:07


it is better to say what you want given input, expected output people get by so nicely without REs some may not know them at all. I suspect your second slash is off by a char but it hard to be sure :) off hand I cant recall off hand if the trailing ? makes it longest or shortest matching, also asumung ther is an inplicit 's' before first slash .... so one way that may be on the right track iis parse/all string [ some[thru "blah" mark: opt["." copy ext to " " (print ["."ext] remove/part :mark length? ext ) ] ] ] On Thu, 26 Feb 2004, Brondo, Greg wrote:

 [3/15] from: Greg:Brondo:allegiancetelecom at: 27-Feb-2004 8:46


Thanks for the reply. This will only work once though? Or will it work on many lines (returning the match each time -- like a loop) ?

 [4/15] from: Greg:Brondo:allegiancetelecom at: 27-Feb-2004 10:28


ok, it appears that 'any' or 'some' will traverse the entire input like I need. Not that I understand it fully but at least it appears to work.

 [5/15] from: nitsch-lists:netcologne at: 27-Feb-2004 18:12


Am Freitag, 27. Februar 2004 17:28 schrieben Sie:
> ok, it appears that 'any' or 'some' will traverse the entire input like I > need. Not that I understand it fully but at least it appears to work. >
Yes, its like a loop. the difference is how the part after the loop is handled. 'any -> 0-n matches, 'some -> 1-n matches. parse string[ "start" any ["middle"] "end" ]
>> parse "start middle end"[ "start" any ["middle"] "end" ]
== true
>> parse "start end"[ "start" any ["middle"] "end" ]
== true
>> parse "start middle end"[ "start" some ["middle"] "end" ]
== true
>> parse "start end"[ "start" some ["middle"] "end" ]
== false -Volker

 [6/15] from: Greg:Brondo:allegiancetelecom at: 16-Mar-2004 10:08


Where are things like open/lines/direct documented? If I execute 'help open' I can see 'open/lines' and 'open/direct' but no the 'open/lines/direct'. How is a newcomer to this language supposed to 'know' these things? Not to sound like a whiner but I *really* want to use this language I'm just having trouble convincing myself to use it for any projects due to the lack of thorough docs and the 'black box' nature of it...... Instead I'm having to look into something like Ruby (or Python) for my clients project.... Thanks! Greg B.

 [7/15] from: maximo:meteorstudios at: 16-Mar-2004 11:46


you've just discovered the main issue with rebol. there are a lot of docs on the rebol.com site. many things are documented on this list only. searching the list archives is probably the most potent store of information. I think that the reason the list is so helpfull is that seasoned rebolers sympathise with this issue and are eager to minimise that pain. Often, using 'help and 'source are the only ways to really discover stuff. Another good place to search for stuff is in the pdf version of the official rebol guide. There are many excellent arcticles, still hanging around on www.rebolforces.com If you look up the ref-words application in the docs section of the rebol desktop, you will also get another view of the rebol functions. plus it stores examples and some additional usefull tidbits of info for many words. note that some of the things I mentioned are not up to date for the latest releases, but those changes are ALL covered in the rebol.com release documentation. HTH !!! -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun.

 [8/15] from: rlist:techscribe at: 16-Mar-2004 10:11


Hi Greg. I'm not sure whether or not you realize that whenever help documents something like open/lines and help also documents something like open/direct then you can also use the combination of the two: open/lines/direct Brondo, Greg wrote:

 [9/15] from: greggirwin:mindspring at: 16-Mar-2004 11:24


Hi Greg, BG> Where are things like open/lines/direct documented? If I execute 'help BG> open' I can see 'open/lines' and 'open/direct' but no the BG> 'open/lines/direct'. How is a newcomer to this language supposed to 'know' BG> these things? Max gave you a good general answer, so I'll just add that /lines and /direct are just two separate refinements. When you do HELP OPEN in the console, they will both be listed, each on their own line. The Core PDF guide also lists them. Along with new functionality, the View 1.3 project from RT is looking at improving docs, just FYI. -- Gregg

 [10/15] from: nitsch-lists:netcologne at: 16-Mar-2004 19:20


On Dienstag, 16. M=E4rz 2004 17:08, Brondo, Greg wrote:
> Where are things like open/lines/direct documented? If I execute 'help > open' I can see 'open/lines' and 'open/direct' but no the > 'open/lines/direct'. How is a newcomer to this language supposed to 'know' > these things? >
because thats refinements. And refinements can be used in combination. (makes not always sense though ;) so open/lines/direct handles data as lines and does not buffer. now where that is documented i can't remember, i guess in the /core manual? I guess most people ask here.. ;)
> Not to sound like a whiner but I *really* want to use this language I'm > just having trouble convincing myself to use it for any projects due to the
<<quoted lines omitted: 3>>
> Thanks! > Greg B.
-Volker

 [11/15] from: charles:mougel:spinodo at: 16-Mar-2004 19:31


Elan a =E9crit :

 [12/15] from: tim:johnsons-web at: 16-Mar-2004 11:04


* Brondo, Greg <[Greg--Brondo--allegiancetelecom--com]> [040316 07:36]:
> Where are things like open/lines/direct documented? If I execute 'help > open' I can see 'open/lines' and 'open/direct' but no the
<<quoted lines omitted: 5>>
> Instead I'm having to look into something like Ruby (or Python) for my > clients project....
I use python and rebol about equally. For instance, I have a client who wants a language that can be interlinked with apache, so there is no 'mod rebol' but there is a 'mod python', so I use python... but holy smokes! Rebol is **so** much more streamlined than python. Rebol's help feature is very helpful and in my opinion, better conceived than pythons. At least when you use help in rebol for a non-existing word, you get alternative choices, as opposed to python's choice to throw and exception. Having said that rebol 'help is better conceived, it still has a way to go in implementation. Give rebol a try. The differences between rebol and python is the difference between a sportscar and a long-haul truck. Both have their use. tim -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com

 [13/15] from: Greg:Brondo:allegiancetelecom at: 16-Mar-2004 14:18


Wow! I actually had now clue you could do that....I was likening refinements to method calls....So even on user created functions you can 'chain' or 'pipeline' your refinements? Any code examples to look at? (I guess maybe I can 'source' 'open ? Thanks for the help! Greg B.

 [14/15] from: rotenca:telvia:it at: 16-Mar-2004 21:22


Brondo, Greg,
> Where are things like open/lines/direct documented? If I execute 'help > open' I can see 'open/lines' and 'open/direct' but no the > 'open/lines/direct'. How is a newcomer to this language supposed to 'know' > these things?
Reading docs: http://www.rebol.com/docs/core23/rebolcore-9.html#section-2.3 --- Ciao Romano

 [15/15] from: greggirwin:mindspring at: 16-Mar-2004 14:21


Hi Greg, BG> Wow! I actually had now clue you could do that....I was likening BG> refinements to method calls....So even on user created functions you can BG> 'chain' or 'pipeline' your refinements? Yes, though they aren't really "pipelined" other than syntactically. They can be given in any order, not just the order they are spec'd in the function interface, and any arguments they take must be given in the same order you specify the refinements.
>> fn: func [val /a aa /b bb][
[ print [val a aa b bb] [ ]
>> fn 1
1 none none none none
>> fn/a 1
** Script Error: fn is missing its aa argument ** Near: fn/a 1
>> fn/a 1 2
1 true 2 none none
>> fn/b 1 2
1 none none true 2
>> fn/a/b 1 2 3
1 true 2 true 3
>> fn/b/a 1 2 3
1 true 3 true 2 BG> Any code examples to look at? (I guess maybe I can 'source' 'open ? Nope; OPEN is a native. -- Gregg

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted