Re: Eye Reasoner Builtin/N3 question/challenge

Not a regex expert, but have you tried using a non-greedy wildcard before the number:
.*?([\.\d]+).*

(Seems to work for your examples, at least.)

W

> On Oct 3, 2022, at 1:51 PM, tim duval <tim.duval11@gmail.com> wrote:
> 
> I'm using regex101 to craft expressions as well.
> The need I have is to extract the number from a string regardless of what is in it.
> so the string could be "13.4 kV" or "Come, mister 13.4 tally man" or "tally me banana 13.4"
> 
> How do we handle escape sequences if they are required then??? 
> unless there's a regexp that does the same without \?
> 
> 
> On Mon, Oct 3, 2022 at 1:44 PM William Van Woensel <william.vanwoensel@gmail.com <mailto:william.vanwoensel@gmail.com>> wrote:
> Hi Tim
> 
> Note that the regex doesn’t match the “kV” at the end of your string. Also, the regex must contain at least one group (don’t think the negative lookahead counts). This one works on regex101.com <http://regex101.com/>:
> 
> ^(?!.*\..*\.)([.\d]+) kV$
> 
> The escaped version does not work with eye but it does with jen3:
> 
> (?!.*\\..*\\.)([.\\d]+) kV
> 
> So, it must be a difference between prolog and java ..
> 
> 
> W
> 
>> On Oct 3, 2022, at 1:19 PM, tim duval <tim.duval11@gmail.com <mailto:tim.duval11@gmail.com>> wrote:
>> 
>> any reason why this is not working????
>> 
>> @prefix string: <http://www.w3.org/2000/10/swap/string# <http://www.w3.org/2000/10/swap/string#>> .
>> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema# <http://www.w3.org/2000/01/rdf-schema#>> .
>> @prefix : <http://example.org/ <http://example.org/>> .
>> 
>> { ("13.4 kV" "^(?!.*\\..*\\.)[.\\d]+$") string:scrape ?s . }
>> => { :test :has ?s } .
>> 
>> On Mon, Oct 3, 2022 at 12:57 PM tim duval <tim.duval11@gmail.com <mailto:tim.duval11@gmail.com>> wrote:
>> will do!! thanks!!!!
>> 
>> 
>> On Mon, Oct 3, 2022 at 12:55 PM Shaw, Ryan <ryanshaw@unc.edu <mailto:ryanshaw@unc.edu>> wrote:
>> 
>> 
>> > On Oct 3, 2022, at 12:43 PM, tim duval <tim.duval11@gmail.com <mailto:tim.duval11@gmail.com>> wrote:
>> > 
>> > Regarding regular expressions:
>> > I find that string:matches() returns a boolean whether or not the string matches the regular expression,
>> > I am looking to extract the number from the string based on the regular expression.
>> 
>> Check out string:scrape
>> https://w3c.github.io/N3/spec/string.html#vocab_string_scrape <https://w3c.github.io/N3/spec/string.html#vocab_string_scrape>

Received on Monday, 3 October 2022 17:59:13 UTC