Re: regular expression sequence

2010-03-30 Thread Mark J. Reed
Leaving out the parentheses changes the meaning because they group as well as capture. #"a(b|c)d" matches either "abd" or "acd". #"ab|cd" matches either "ab" or "cd". On Tuesday, March 30, 2010, Glen Rubin wrote: > thx that works great!  i guess I can also just leave out the > parenthesis all t

Re: regular expression sequence

2010-03-30 Thread Glen Rubin
thx that works great! i guess I can also just leave out the parenthesis all together. but, what if i wanted just the portion inside?? the duplicate I wanted to get rid of? also any way to return the sequence without all those bars or do i have to use a seperate regex and or filter? On Mar 30,

Re: regular expression sequence

2010-03-30 Thread Mark J. Reed
Addendum: I highly recommend Jeffrey Friedl's book _Mastering_Regular_Expressions_ if you want to learn how to use regexes well. There are also a number of introductions/tutorials online, but I'm not familiar enough with them to recommend any. On Tue, Mar 30, 2010 at 12:50 PM, Mark J. Reed wrote

Re: regular expression sequence

2010-03-30 Thread Mark J. Reed
Parentheses capture - anything that matches a parenthesized portion of a regular expression is returned as part of the result of the match: user=> (re-seq #"a(.)c" "abc") (["abc" "b"]) If you don't want that behavior, you can use the special non-capturing syntax, (?:...): user=> (re-seq #"a(?:.)

Re: regular expression sequence

2010-03-30 Thread Glen Rubin
The result is a little bit strange still, since I am getting dupliates. First, it returns the string I want 49|00|12 12|a9|a4|ff but then it also returns the same string without the first and last 4 characters, e.g. 12|12|a9| Also, how come I don't need to escape the | inside the pare

Re: regular expression sequence

2010-03-30 Thread Meikel Brandmeyer
Hi, you have to escape the |. user=> (re-seq #"49\|00\|([0-9a-f|]+)\|a4\|ff" "a5|a5|49|23|49|00|12| fc|5e|a4|ff|a7|49|00|ee|d3|a4|ff|ae") (["49|00|12|fc|5e|a4|ff|a7|49|00|ee|d3|a4|ff" "12|fc|5e|a4|ff|a7|49|00| ee|d3"]) However this will be greedy... Sincerely Meikel -- You received this messa

regular expression sequence

2010-03-30 Thread Glen Rubin
I am having trouble with the re-seq regular expression form. I am not an expert on regex, so this is probably part of my problem. I have a k12 text file, basically it is hex broken up by '|' . I would like to grab all the hex between two hex numbers (sample text below). For example, I might wa