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 <markjr...@gmail.com> wrote:
> 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(?:.)c" "abc")
> ("abc")
>
> You don't have to escape pipes or any other special characters inside
> a character class (that is, between [...]), because characters lose
> their special meanings there: [.*] matches either a period or an
> asterisk and has no relationship to the "any character" symbol or
> "zero or more" repetition operator.
>
> The only special things inside a character class are a leading '^',
> which negates the class, and a '-' in the middle, which makes a range:
> [^a-z] matches any single character that is not a lowercase letter (of
> the English alphabet).  Position matters: [-^] matches a literal
> hyphen or caret, and [] is not an empty character class but a syntax
> error (an unclosed character class that so far includes a literal ']'
> character).
>
>
> On Tue, Mar 30, 2010 at 12:37 PM, Glen Rubin <rubing...@gmail.com> wrote:
>> 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 parenthesis?
>>
>> thanks Meikel!!
>>
>>
>> On Mar 30, 10:59 am, Meikel Brandmeyer <m...@kotka.de> wrote:
>>> 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 message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>> To unsubscribe from this group, send email to 
>> clojure+unsubscribegooglegroups.com or reply to this email with the words 
>> "REMOVE ME" as the subject.
>>
>
>
>
> --
> Mark J. Reed <markjr...@gmail.com>
>



-- 
Mark J. Reed <markjr...@gmail.com>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to