Re: common ways to run regex against either Hickory HTML or zippers?

2022-02-03 Thread Laws
t would let me easily pick out the data I need. However, for the most > part, the only thing I really need off this page is the CVEs, which look > like this: > > CVE-2021-40539 > > I'm thinking I might write regex against the plain text of the page, but > I'm also

Re: common ways to run regex against either Hickory HTML or zippers?

2022-02-02 Thread Harold
ector-that-uses-regex - The were also having problems with text encoding, hopefully you wont. hth, -Harold On Wednesday, February 2, 2022 at 1:22:53 PM UTC-7 lawrence...@gmail.com wrote: > Assume I've been cursed to scrape HTML. If I convert the pages to Hickory > I end up with a

Re: common ways to run regex against either Hickory HTML or zippers?

2022-02-02 Thread Cora Sutton
If all you're looking for is the format CVE--N then by all means just use regex against the plain text of the page. If you need to do dom traversal then jsoup is a good choice. Otherwise, like Mark said, tree-seq is a great choice if you don't want to play with clojure.walk. On

Re: common ways to run regex against either Hickory HTML or zippers?

2022-02-02 Thread Mark Nutter
: > > CVE-2021-40539 > > I'm thinking I might write regex against the plain text of the page, but > I'm also curious, is it common to take something like Hiccup or Hickory or > a zipper and run regex through it? If yes, how is that done? > > A small part of the

common ways to run regex against either Hickory HTML or zippers?

2022-02-02 Thread lawrence...@gmail.com
e is the CVEs, which look like this: CVE-2021-40539 I'm thinking I might write regex against the plain text of the page, but I'm also curious, is it common to take something like Hiccup or Hickory or a zipper and run regex through it? If yes, how is that done? A sma

Re: regex in edn?

2019-03-29 Thread Alex Miller
There are edn impls in at least 15 languages so the problem is wider than just java and js. -- 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 -

Re: regex in edn?

2019-03-29 Thread Matching Socks
How would you resolve the problem "Rich Hickey" mentioned on the page you linked? "The lack of portability for regexes"... True, *some* regex patterns mean the same thing in the JVM and JS, but in general a regex pattern is not a portable value; it may mean something diff

Re: regex in edn?

2019-03-29 Thread Ikuru Kanuma
Thanks for the reply! Glad to have confirmations. -- 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. T

Re: regex in edn?

2019-03-29 Thread Alexander Yakushev
Not adding much to what you've already said, but a custom reader tag is exactly what I would reach out for in this situation. -- 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 post

regex in edn?

2019-03-29 Thread Ikuru Kanuma
Hi, just writing this out of pure curiosity. Background: 1. I thought I could write regex literals like this in an edn file containing configurations: :some-parameter #"foo" But reading this with e.g. clojure.edn/read-string causes an error No dispatch macro for: " 2.

Re: Confusing Regex Behavior

2018-12-04 Thread Matching Socks
See also Java's regex "Comparison to Perl 5" at https://docs.oracle.com/javase/9/docs/api/java/util/regex/Pattern.html. However, you are in for a treat! Perl is insanely great. Clojure is simply great. -- You received this message because you are subscribed to the Google

Re: Confusing Regex Behavior

2018-12-04 Thread Randy J. Ray
...) Randy On Tue, Dec 4, 2018 at 1:37 PM Justin Smith wrote: > You don't need to use re-matcher in that example - the output of re-find > with the regex and the string is identical. If you are using the matcher to > collect a series of matches in one string, you can also uses re-seq whi

Re: Confusing Regex Behavior

2018-12-04 Thread Justin Smith
You don't need to use re-matcher in that example - the output of re-find with the regex and the string is identical. If you are using the matcher to collect a series of matches in one string, you can also uses re-seq which returns a lazy-seq of the matches of your regex in the string. On Tue

Re: Confusing Regex Behavior

2018-12-04 Thread Randy J. Ray
erhut wrote: > The doc string for re-matches says that it > uses java.util.regex.Matcher.matches(). The Java doc page for the class > java.util.regex.Matcher [1] says "The matches > <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Matcher.html#matches--> > method

Re: Confusing Regex Behavior

2018-12-04 Thread Andy Fingerhut
The doc string for re-matches says that it uses java.util.regex.Matcher.matches(). The Java doc page for the class java.util.regex.Matcher [1] says "The matches <https://docs.oracle.com/javase/8/docs/api/java/util/regex/Matcher.html#matches--> method attempts to match the entire inp

Confusing Regex Behavior

2018-12-04 Thread Randy J. Ray
I must be doing something wrong here, but I cannot figure this out. The following results in "nil" from re-matches: (re-matches #"\[((\d+)-(\d+)-(\d+) (\d\d):(\d\d))\] (.*)" "[1518-05-27 00:42] falls asleep\n") This, however, properly matches the line and produces the backreferences: (re-find (

Re: What is wrong with this simple Regex?

2017-03-08 Thread piastkrakow
Thank you. On Wednesday, March 8, 2017 at 12:11:26 PM UTC-5, Sean Corfield wrote: > > Because you have a space in your regex, it is treated as a range, from > space to underscore which matches a lot of characters. Move the – to the > start: > > > >

Re: What is wrong with this simple Regex?

2017-03-08 Thread Sean Corfield
Because you have a space in your regex, it is treated as a range, from space to underscore which matches a lot of characters. Move the – to the start:     (clojure.string/replace phone #"[- _]" garbage) Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN An A

What is wrong with this simple Regex?

2017-03-08 Thread piastkrakow
I built a string matching system, so when we get new records, from crawling the web, we can find out if we already have the same information in the database. There are many parameters to tune, and so I wanted to generate the F1 score for the different parameters. I can easily test True Positives

Re: how do I clojure.string/replace regex characters? Escaping gives me StringIndexOutOfBoundsException

2014-08-05 Thread Daniel Compton
e: > > Or even more simply, since the thing you want to replace is a single > character, you do not need a regex to match it, but can match a string that > is not a regex at all, e.g.: > > (st/replace "**username" "*" "$") > > The doc string

Re: how do I clojure.string/replace regex characters? Escaping gives me StringIndexOutOfBoundsException

2014-08-04 Thread Andy Fingerhut
Or even more simply, since the thing you want to replace is a single character, you do not need a regex to match it, but can match a string that is not a regex at all, e.g.: (st/replace "**username" "*" "$") The doc string for clojure.string/replace is fairly ex

Re: how do I clojure.string/replace regex characters? Escaping gives me StringIndexOutOfBoundsException

2014-08-04 Thread Vincent H
; => (f [:!!username "michael"]) > > StringIndexOutOfBoundsException String index out of range: 1 > java.lang.String.charAt (String.java:695) > > or: > > => (def f (fn [%] (st/replace (name (first %)) #"\*" "$"))) > > => (f [:**

how do I clojure.string/replace regex characters? Escaping gives me StringIndexOutOfBoundsException

2014-08-04 Thread larry google groups
I'm working on a website with a frontender who asked to be able to save JSON maps that contain field names such as: "$$hashKey" : "00C" The dollar signs are a violation of MongoDB limits on field names, so i need to convert to something else and then convert back. So I thought I would convert

Re: regex strings

2014-05-27 Thread Stephen Gilardi
clojure.string/replace replaces the portion of the string matched by the regex with the replacement. If you add ".*" to the regex, the regex will match the entire input string and the form will evaluate to "First". --Steve On May 27, 2014, at 11:24 AM, Glen Rubin wrote:

regex strings

2014-05-27 Thread Glen Rubin
ng/replace nameidstring #"Name:\s(\w+){1},(\w+){1}" "$2") Unfortunately, this gives me the First name along with ID: GA88192 since i specified a single word {1} in my regex above I don't understand why this is happening. THank you for any advice -- You received this messag

Re: regex

2014-04-18 Thread Thumbnail
Of course! Thank you. On Friday, 18 April 2014 15:33:39 UTC+1, A. Webb wrote: > > > > On Friday, April 18, 2014 8:28:03 AM UTC-5, Thumbnail wrote: >> >> >> ... I decided that the terminal state would always be at index 0 ... >>> >> >> Shouldn't a DFA allow for *any* *set* of states to be termina

Re: regex

2014-04-18 Thread A. Webb
On Friday, April 18, 2014 8:28:03 AM UTC-5, Thumbnail wrote: > > > I had a couple of insights. First, to allow the dfa to be generated >> programmatically, I changed it from a map to a vector. This means >> that the next state can just be an integer. Second, I decided that >> the terminal s

Re: regex

2014-04-18 Thread Thumbnail
> I had a couple of insights. First, to allow the dfa to be generated > programmatically, I changed it from a map to a vector. This means > that the next state can just be an integer. Second, I decided that > the terminal state would always be at index 0 ... > Shouldn't a DFA allow for *a

Re: paredit+regex question

2014-03-05 Thread Phillip Lord
Erlis Vidal writes: > @Phillip: Wow! I'm wondering why paredit doesn't fix this issue. Thanks for > the patch! Because this syntax is specific to clojure and not all lisps! Hopefully, I'll get around to submitting a patch to paredit at some point. If not me, I am sure someone will do it! Phil

Re: paredit+regex question

2014-03-05 Thread Erlis Vidal
h > > > On Monday, March 3, 2014 10:09:47 PM UTC+1, Erlis Vidal wrote: > >> Hi this is not a clojure question but I'm sure some one on this list can >> help me. >> >> I'm trying to write a regex using paredit and it looks like I cannot >> write someth

Re: paredit+regex question

2014-03-04 Thread Oleh
or issues, raise them here: https://github.com/abo-abo/lispy/issues?state=open. Oleh On Monday, March 3, 2014 10:09:47 PM UTC+1, Erlis Vidal wrote: > > Hi this is not a clojure question but I'm sure some one on this list can > help me. > > I'm trying to write a regex u

Re: paredit+regex question

2014-03-04 Thread Phillip Lord
Erlis Vidal writes: > Hi this is not a clojure question but I'm sure some one on this list can > help me. > > I'm trying to write a regex using paredit and it looks like I cannot write > something like this > > #"mypattern \d" > > whenever

Re: paredit+regex question

2014-03-03 Thread Magnar Sveen
Magnar On Monday, March 3, 2014 10:09:47 PM UTC+1, Erlis Vidal wrote: > > Hi this is not a clojure question but I'm sure some one on this list can > help me. > > I'm trying to write a regex using paredit and it looks like I cannot write > something like this >

paredit+regex question

2014-03-03 Thread Erlis Vidal
Hi this is not a clojure question but I'm sure some one on this list can help me. I'm trying to write a regex using paredit and it looks like I cannot write something like this #"mypattern \d" whenever I type the character \ I see the text "Escaping character...&

Re: string/replace regex help

2014-01-16 Thread Kuba Roth
Jan 16, 2014 at 1:02 PM, Kuba Roth wrote: > Hi, > This is more of a regex specific question the clojure, but anyway... > I have the a multiline string as follow: > (def myText "aSTART > > > END > ee > ff > ggg > START > >

Re: string/replace regex help

2014-01-16 Thread John Wiseman
(clojure.string/replace myText #"(?s)START.*?END" "==") ;; "a==\nee\nff\nggg\n==\n\n" (?s) specifies multi-line mode, *? is the non-greedy form of *. On Thu, Jan 16, 2014 at 1:02 PM, Kuba Roth wrote: > Hi, > This is more of a

string/replace regex help

2014-01-16 Thread Kuba Roth
Hi, This is more of a regex specific question the clojure, but anyway... I have the a multiline string as follow: (def myText "aSTART END ee ff ggg START ii E END ") .. and I need to replace all text between START END 'k

Obtain name of interface from java file, regex + slurp doesn't works

2013-11-27 Thread Simone Mosciatti
Hi all, I am trying to parse some java source file that contain the definition of an interface, what I need is to get the name of the interface, what methods it defines and what other interfaces it extend. I used a regex (there is any clever way other than analyze the source ?) that works

Destructuring Bind on Regex

2013-02-09 Thread JvJ
I wrote this little macro today that lets you do it. However, I feel like it was implemented in a pattern match library or something... but I'm not sure. Someone let me know if I'm re-inventing the wheel. If I'm not, here's the code: (defn re-bind-fn [str re bnds act & forms] `(let [~'__TE

Re: using regex reader macro with generated code

2011-06-16 Thread Daniel Werner
On Jun 16, 4:47 am, Alex Baranosky wrote: > IS it possible to use the regex reader macro #"" with generated code?  What > I mean is do something like: > > #"${(join "|" (range 1 1))}" > > I'm using ${...} to mean string interpolation,

Re: using regex reader macro with generated code

2011-06-16 Thread Rasmus Svensson
2011/6/16 Alex Baranosky : > IS it possible to use the regex reader macro #"" with generated code?  What > I mean is do something like: > #"${(join "|" (range 1 1))}" > I'm using ${...} to mean string interpolation, though I know Clojure doesn&#x

Re: using regex reader macro with generated code

2011-06-16 Thread Ken Wesson
On Wed, Jun 15, 2011 at 10:47 PM, Alex Baranosky wrote: > IS it possible to use the regex reader macro #"" with generated code?  What > I mean is do something like: > #"${(join "|" (range 1 1))}" > I'm using ${...} to mean string interpolation, t

using regex reader macro with generated code

2011-06-15 Thread Alex Baranosky
IS it possible to use the regex reader macro #"" with generated code? What I mean is do something like: #"${(join "|" (range 1 1))}" I'm using ${...} to mean string interpolation, though I know Clojure doesn't have that syntax. Is there a way to g

Re: Simple Regex Question

2010-08-22 Thread CuppoJava
t; > > > > > > Hi Everyone, > > > I'm extremely stuck on this simple regex question, which I'm sure > > someone with a little more experience will be able to write in a > > second. I would really appreciate the help. > > > Given a string consisting

Re: Simple Regex Question

2010-08-22 Thread Luka Stojanovic
On Sunday 22 August 2010 01:11:38 CuppoJava wrote: > Hi Everyone, > > I'm extremely stuck on this simple regex question, which I'm sure > someone with a little more experience will be able to write in a > second. I would really appreciate the help. > > Given a str

Re: Simple Regex Question

2010-08-21 Thread David Sletten
g with currently. > -Patrick > > On Aug 21, 8:45 pm, Chouser wrote: >> On Sat, Aug 21, 2010 at 7:11 PM, CuppoJava >> wrote: >>> Hi Everyone, >> >>> I'm extremely stuck on this simple regex question, which I'm sure >>> someone with a lit

Re: Simple Regex Question

2010-08-21 Thread CuppoJava
Wow that's so short! Thanks Chouser! I will abstain from showing the awful hack that I've been working with currently. -Patrick On Aug 21, 8:45 pm, Chouser wrote: > On Sat, Aug 21, 2010 at 7:11 PM, CuppoJava wrote: > > Hi Everyone, > > > I'm extremely st

Re: Simple Regex Question

2010-08-21 Thread Chouser
On Sat, Aug 21, 2010 at 7:11 PM, CuppoJava wrote: > Hi Everyone, > > I'm extremely stuck on this simple regex question, which I'm sure > someone with a little more experience will be able to write in a > second. I would really appreciate the help. > > Given a str

Simple Regex Question

2010-08-21 Thread CuppoJava
Hi Everyone, I'm extremely stuck on this simple regex question, which I'm sure someone with a little more experience will be able to write in a second. I would really appreciate the help. Given a string consisting of a's, b's, and spaces: "aaa bbb abb ab bb"

Re: RegEx

2010-07-31 Thread Rafael Peixoto de Azevedo
e letter gets appended to the end of the number. > > This seems like a great place to use regexhow would one craft a > pattern for this? > > Thanks > > Base > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" gro

Re: RegEx

2010-07-30 Thread Frederick Polgardy
If you want a single regex that matches either M123.5554 or 1234.435M, you need to use the OR form (a|b): ([ML]\d+\.\d+|\d+\.\d+[ML]) where: [ML] matches M or L \d+ matches 1 or more digits \. matches a . -Fred -- Science answers questions; philosophy questions answers

Re: RegEx

2010-07-30 Thread rob levy
at would be > > M123.5554 > or 1234.435M > > i.e. - the letter gets appended to the end of the number. > > This seems like a great place to use regexhow would one craft a > pattern for this? > > Thanks > > Base > > -- > You received this message bec

RegEx

2010-07-30 Thread Base
the number. This seems like a great place to use regexhow would one craft a pattern for this? Thanks Base -- 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 post

Re: REPL vs Script + Regex Problem!

2010-02-03 Thread Michał Marczyk
On 3 February 2010 08:58, Meikel Brandmeyer wrote: > condp was specifically designed to be a scheme-like cond with :>> > support and such. Well, I like condp a lot (really, condp FTW! -- definately worth a define-syntax in Scheme :-)), but it's nothing like Scheme's cond (which is a good thing, a

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Meikel Brandmeyer
293212 > > Basically this would allow you to write things like > > (scond [(re-matches first-regex line) :>> process-result-1] >           [(re-matches second-regex line) :>> process-result-2] >           [(re-matches third-regex line)] ; return the matches without > f

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Michał Marczyk
[(re-matches first-regex line) :>> process-result-1] [(re-matches second-regex line) :>> process-result-2] [(re-matches third-regex line)] ; return the matches without further processing, if any [:else (give-up)]) Although I suppose Meikel Brandmeyer'

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Wardrop
l\)each:" line)) > >   (first (re-matches #".*(\.[0-9a-zA-Z]+)" line))]) > > A simplified version: > > (some #(first (re-matches % line)) [first-regex second-regex]) > > Sincerely, > Michal -- You received this message because you are subscribed to the Goo

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Michał Marczyk
rsion: (some #(first (re-matches % line)) [first-regex second-regex]) Sincerely, Michal -- 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 moder

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread ataggart
It occurs to me you could use 'some instead of nested if-lets: (some identity [(first (re-matches #"([0-9]+) byte\(null\)each:" line)) (first (re-matches #".*(\.[0-9a-zA-Z]+)" line))]) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread ataggart
t; not to show when this is run as a script, but why are the > aforementioned strings not being output? Just a guess, but perhaps none of your tests pass: user=> (cond false :foo) nil > Anyway, I not only want the regex to be used > in the condition expression, but also want t

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Meikel Brandmeyer
the sequence is not realised. In the repl it is (the printed nils) and hence the println's are executed. > While you're at it, you may be able to help me with an additional > problem I'm trying to tackle. As you can see if the above code, I'm > trying to match on certain

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Wardrop
t; > the strings "Byte pattern!" and "File pattern!". I expect the nil's > > not to show when this is run as a script, but why are the > > aforementioned strings not being output? > > > While you're at it, you may be able to help me with an additi

Re: REPL vs Script + Regex Problem!

2010-02-02 Thread Kevin Downey
t? > > While you're at it, you may be able to help me with an additional > problem I'm trying to tackle. As you can see if the above code, I'm > trying to match on certain lines of a text file. I'm using "cond" to > do this with as a switch statement is t

REPL vs Script + Regex Problem!

2010-02-02 Thread Wardrop
show when this is run as a script, but why are the aforementioned strings not being output? While you're at it, you may be able to help me with an additional problem I'm trying to tackle. As you can see if the above code, I'm trying to match on certain lines of a text file. I'm u

Re: File and Regex Utils

2009-10-12 Thread Robert Stehwien
> While doing some scripting and as a learning I put together some file and > regex utilities. Reading though parts of clojure-contrib was a great eye > opener. Still needs some cleanup, doc, and maybe a few more functions. I > could wrap all the java.io.File functions but most are

File and Regex Utils

2009-10-11 Thread Robert Stehwien
While doing some scripting and as a learning I put together some file and regex utilities. Reading though parts of clojure-contrib was a great eye opener. Still needs some cleanup, doc, and maybe a few more functions. I could wrap all the java.io.File functions but most are just a thin wrapper

Re: Why doesn't regex implement ifn?

2009-08-29 Thread eyeris
egexps. However (filter is-number-regex maybe-numbers) is clear to even programmers that don't understand regexps. On Aug 27, 10:41 am, Sean Devlin wrote: > On Aug 27, 1:06 am, Timothy Pratley wrote: > > > > > > Granted, this wouldn't work for anything that gets passed

Re: Why doesn't regex implement ifn?

2009-08-28 Thread Chas Emerick
On Aug 28, 2009, at 12:13 PM, Chouser wrote: > On Fri, Aug 28, 2009 at 10:01 AM, Shawn > Hoover wrote: >> >> However, unless the platforms agree on literal regex >> syntax (they don't, beyond the basic "asdf|[0-9]+" >> features) will prevent tru

Re: Why doesn't regex implement ifn?

2009-08-28 Thread Chouser
On Fri, Aug 28, 2009 at 10:01 AM, Shawn Hoover wrote: > > However, unless the platforms agree on literal regex > syntax (they don't, beyond the basic "asdf|[0-9]+" > features) will prevent true portability of the literals. This is an interesting and crucial assertion

Re: Why doesn't regex implement ifn?

2009-08-28 Thread Chas Emerick
On Aug 28, 2009, at 10:01 AM, Shawn Hoover wrote: > Why wouldn't #"" produce whatever the corollary regex object is on > each host platform? > > I had a couple suggestions on clojure-dev for ClojureCLR that line > up with the "produce the corollary idea&

Re: Why doesn't regex implement ifn?

2009-08-28 Thread Chouser
on to write Clojure code that can run on >> non-JVM platforms.  So although this idea has come up and >> then been abandoned several times before, I think it's worth >> bringing up again periodically to see what makes sense. > > Why wouldn't #"" produce whatever

Re: Why doesn't regex implement ifn?

2009-08-28 Thread Shawn Hoover
on to write Clojure code that can run on > > non-JVM platforms. So although this idea has come up and > > then been abandoned several times before, I think it's worth > > bringing up again periodically to see what makes sense. > > Why wouldn't #"" produ

Re: Why doesn't regex implement ifn?

2009-08-28 Thread Rich Hickey
on to write Clojure code that can run on >> non-JVM platforms.  So although this idea has come up and >> then been abandoned several times before, I think it's worth >> bringing up again periodically to see what makes sense. > > Why wouldn't #"" produce whatever

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Chas Emerick
has come up and > then been abandoned several times before, I think it's worth > bringing up again periodically to see what makes sense. Why wouldn't #"" produce whatever the corollary regex object is on each host platform? Tangentially, if I think ahead a couple of &#

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Timothy Pratley
> > The only feature I want is the ability to use a regex as a predicate. > Would automatically forcing the first step to get a nice 'nil' be >unacceptable? Sounds good to me! This can be quite easily accommodated: (defn re-fn "Construct a regular expression from

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Sean Devlin
Awesome. +1 On Aug 27, 9:57 pm, Timothy Pratley wrote: > > > The only feature I want is the ability to use a regex as a predicate. > > Would automatically forcing the first step to get a nice 'nil' be > >unacceptable? > > Sounds good to me! > This can

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Sean Devlin
Hmmm... I think you're confusing the issue. Your compliant seems to be more directed at "magic numbers" than regexes. If I understand your argument (which I agree with): ;bad code (filter #"\d+" maybe-numbers) ;good code (let [is-number-regex #"\d+"] (f

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Chouser
n periodically to see what makes sense. >> Oh - it seems like re-seq does the most work so perhaps that is the >> best candidate? > > The only feature I want is the ability to use a regex as a predicate. > So, I'd prefer something like re-matches.  Maybe this isn't the &

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Sean Devlin
Or this: (def number-text? #"^\d$") Which is a savings :) On Aug 27, 5:21 pm, eyeris wrote: > I named is-number-regex poorly. I meant it to be a function that calls > re-matches. Here's a more complete snippet, with better names: > > ; bad code > (filter #&qu

Re: Why doesn't regex implement ifn?

2009-08-27 Thread eyeris
I named is-number-regex poorly. I meant it to be a function that calls re-matches. Here's a more complete snippet, with better names: ; bad code (filter #"^\d+$" maybe-numbers) ; good code (defn re-match? [re s] (not (nil? (re-matches re s (defn number-text? [s] (re-ma

Re: Why doesn't regex implement ifn?

2009-08-27 Thread Sean Devlin
cs might be confusing - so a wrapper > seems more obvious for that. > > Oh - it seems like re-seq does the most work so perhaps that is the > best candidate? The only feature I want is the ability to use a regex as a predicate. So, I'd prefer something like re-matches. Maybe th

Re: Why doesn't regex implement ifn?

2009-08-26 Thread Timothy Pratley
> Granted, this wouldn't work for anything that gets passed to Java, but > the following gist would be a start. > http://gist.github.com/176032 You already have a getPattern method for those cases. Which suggests another solution: (defn re-fn "Uses ss to construct a java.util.Pattern. Return

Re: Why doesn't regex implement ifn?

2009-08-26 Thread Sean Devlin
Well, with a statically typed language this would be a problem. What if we used duck-typing to get around this? Granted, this wouldn't work for anything that gets passed to Java, but the following gist would be a start. http://gist.github.com/176032 Now, We'd still have to address Mr. Pratley'

Re: Why doesn't regex implement ifn?

2009-08-26 Thread Rich Hickey
On Aug 26, 9:46 pm, Timothy Pratley wrote: > > java.util.regex.Pattern > > I imagine a wrapper class could be returned instead that implemented > IFn and Pattern, Unfortunately, Pattern is a final class. Rich --~--~-~--~~~---~--~~ You received this message beca

Re: Why doesn't regex implement ifn?

2009-08-26 Thread Chas Emerick
On Aug 26, 2009, at 9:46 PM, Timothy Pratley wrote: >> java.util.regex.Pattern > > I imagine a wrapper class could be returned instead that implemented > IFn and Pattern, Pattern is a final concrete class, so that's not possible. ...I'm counting down until I

Re: Why doesn't regex implement ifn?

2009-08-26 Thread Timothy Pratley
> java.util.regex.Pattern I imagine a wrapper class could be returned instead that implemented IFn and Pattern, but which function would it call? (re-find m) (re-find re s) (re-groups m) (re-matcher re s) (re-matches re s) (re-pattern s) (re-seq re s) I don't think there is a clear implicit choi

Re: Why doesn't regex implement ifn?

2009-08-26 Thread Chas Emerick
On Aug 26, 2009, at 9:17 PM, Sean Devlin wrote: > Okay, I'm sure this has come up before. I was just wondering if > anyone knew why the regex literal doesn't implement IFn? > > At first glance it seems like the following would be useful: > > user=>(#"\d{3}&q

Why doesn't regex implement ifn?

2009-08-26 Thread Sean Devlin
Okay, I'm sure this has come up before. I was just wondering if anyone knew why the regex literal doesn't implement IFn? At first glance it seems like the following would be useful: user=>(#"\d{3}" "123") true This is defined as... user=>(not (nil? (re-mat

Re: problems with regex

2009-06-21 Thread Stephen C. Gilardi
On Jun 21, 2009, at 4:34 PM, Alpinweis wrote: I am trying some regex in Clojure and I have problems using regex literals. Don't know why the following doesn't seem to work: user=> (re-seq #"\\W+" "the quick brown fox") () user=> (re-seq #"\\w+"

problems with regex

2009-06-21 Thread Alpinweis
I am trying some regex in Clojure and I have problems using regex literals. Don't know why the following doesn't seem to work: user=> (re-seq #"\\W+" "the quick brown fox") () user=> (re-seq #"\\w+" "the quick brown fox") () user=> (r

Re: regex replace all?

2009-04-29 Thread Mark Derricutt
Cool, I think I'll stick to my current one which lets me easily use multiple replacements in one call. -- Discouragement is a dissatisfaction with the past, a distaste for the present, and a distrust of the future - Maree De Jong, Life Church New Zealand. http://www.talios.com Sent from Auckland

Re: regex replace all?

2009-04-29 Thread Baishampayan Ghose
Mark Derricutt wrote: > Does clojure come with a built-in regex replace method? I see ones for > re-split, re-seq etc. but nothing for a simple replace, I've been using: > > (defn replace-all > [st reps] > (reduce #(.replaceAll %1 (first %2) (second %2)) st reps

regex replace all?

2009-04-29 Thread Mark Derricutt
Does clojure come with a built-in regex replace method? I see ones for re-split, re-seq etc. but nothing for a simple replace, I've been using: (defn replace-all [st reps] (reduce #(.replaceAll %1 (first %2) (second %2)) st reps)) but wondered if I was just missing some bu

Re: nth with regex Matchers

2009-02-22 Thread Frantisek Sodomka
79a738cbe7f41e9 Frantisek On 22 Ún, 02:37, Chouser wrote: > On Sat, Feb 21, 2009 at 1:34 PM, Frantisek Sodomka wrote: > > > nth claims to also work on regex Matchers: > > > user=> (doc nth) > > - > > clojure.core/nth > > ([coll index] [c

Re: nth with regex Matchers

2009-02-21 Thread Chouser
On Sat, Feb 21, 2009 at 1:34 PM, Frantisek Sodomka wrote: > > nth claims to also work on regex Matchers: > > user=> (doc nth) > - > clojure.core/nth > ([coll index] [coll index not-found]) > Returns the value at the index. get returns nil if

nth with regex Matchers

2009-02-21 Thread Frantisek Sodomka
nth claims to also work on regex Matchers: user=> (doc nth) - clojure.core/nth ([coll index] [coll index not-found]) Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works

Re: anyone experience with brics.automaton regex engine?

2009-01-13 Thread bOR_
For posterity: got it working! Here is how (just ignore all the gene amino window size like words, they are specific for my code) (add-classpath "file:///linuxhome/tmp/boris/automaton.jar") (import '(brics.automaton.RegExp)) (import '(brics.automaton.Automaton)) (import '(brics.automaton.RunAutom

Re: anyone experience with brics.automaton regex engine?

2008-12-10 Thread bOR_
Hired a monkey to hit random keys on my keyboard, and eventually figured out how to get the automaton working. RegExp r = new RegExp("ab(c|d)*"); Automaton a = r.toAutomaton(); String s = "abcccdc"; System.out.println("Match: " + a.run(s)); // prints: true (add-classpath "file:///home/boris/pro

anyone experience with brics.automaton regex engine?

2008-12-09 Thread bOR_
Hi all. Ported my research project to clojure, and now just benchmarking parts of it. I am currently spending about 5/6th of all simulation time doing regular expressions, so I looked into alternative regex engines, optimizing the regular expression and trying to find out whether clojure'

Re: Building regex pattern literals (Noob question)

2008-12-03 Thread Blaine
quot;bab")  ; but this, in all its noobness, is > > not > > ; Evaluation aborted. > > user> #(str "a" ".*") > > #  ; what > > is this thing?  can I use it somehow? > > It's a function!  You could have built the same thing like th

  1   2   >