|
man 2007 ya'll old
|
# ? Oct 18, 2012 23:31 |
|
|
# ? Jun 11, 2024 19:44 |
|
java 7 added support for named groups in regexes e.g. (?<foo>\w+)(?<bar>\d+) is there some way to get the names of all the groups from a Matcher object if i dont know them in advance? (like how i can get all the values of the groups by calling group(i) for 0<i<=groupCount() )
|
# ? Oct 19, 2012 02:34 |
|
i mean preferably without doing somematcher.pattern.toString() and using... a regex... to find chevron-enclosed names lol
|
# ? Oct 19, 2012 03:00 |
|
Milkie Galore posted:i mean preferably without doing somematcher.pattern.toString() and using... a regex... to find chevron-enclosed names lol This is the one true way.
|
# ? Oct 19, 2012 03:21 |
|
Milkie Galore posted:i mean preferably without doing somematcher.pattern.toString() and using... a regex... to find chevron-enclosed names lol that's how stargate did it
|
# ? Oct 19, 2012 03:28 |
|
Milkie Galore posted:java 7 added support for named groups in regexes e.g. java regex protip. group(0) always refers to the entire matched string. group(1) is the first one, and the last one is groupcount()+1. its loving stupid but thats the way it works. as far as names go, i dont see any way to get the name if you have the index. you'll have to regex the regex. altho maybe theres a commons lib that adds that functionality 4 u
|
# ? Oct 19, 2012 03:32 |
|
tbh theres probably a way better way to do what u want tho.
|
# ? Oct 19, 2012 03:40 |
|
dynamic regex group naming smells of p-language hackery.
|
# ? Oct 19, 2012 03:43 |
|
Shaggar posted:regex group naming smells
|
# ? Oct 19, 2012 03:45 |
|
basically anything that's not compile-time checked like using strings for poo poo is the worst
|
# ? Oct 19, 2012 03:48 |
|
i hope you're at least burying this regex inside some class with a simple external API
|
# ? Oct 19, 2012 03:49 |
|
Shaggar posted:java regex protip. group(0) always refers to the entire matched string. group(1) is the first one, and the last one is groupcount()+1. its loving stupid but thats the way it works. the last one is groupcount(), note that i used <= not < Shaggar posted:tbh theres probably a way better way to do what u want tho. i dont think there really is unfortunately, other than insisting the user uses numbers rather than names vapid cutlery posted:basically anything that's not compile-time checked like using strings for poo poo is the worst yeah as best i can/need to. its a peculiar one, its user-supplied but at compile time (its part of a parser generator)
|
# ? Oct 19, 2012 03:56 |
|
You have to cheat:code:
|
# ? Oct 19, 2012 04:06 |
|
lol
|
# ? Oct 19, 2012 04:07 |
|
ah i saw that private map but didn't know there was a way to get at it, thanks homercles!
|
# ? Oct 19, 2012 04:08 |
|
also brb throwing up
|
# ? Oct 19, 2012 04:08 |
|
Milkie Galore posted:the last one is groupcount(), note that i used <= not <
|
# ? Oct 19, 2012 05:03 |
|
Shaggar posted:tbh theres probably a way better way to do what u want tho. Write it in Perl.
|
# ? Oct 19, 2012 08:23 |
|
perl regex is fully sick
|
# ? Oct 19, 2012 09:48 |
|
Nomnom Cookie posted:Using user-supplied regexes opens you to a complexity DoS more importantly it makes for a nasty api may I suggest code:
|
# ? Oct 19, 2012 10:07 |
NeoHentaiMaster posted:Write it in Perl.
|
|
# ? Oct 19, 2012 10:35 |
|
Nomnom Cookie posted:Using user-supplied regexes opens you to a complexity DoS yes - though the user in this case is another coder, using [the output of] my code in theirs (think antlr,yacc,sablecc etc) so it doesnt really matter and theyre unlikely to do this to themselves and its not my problem if they do its not like im running a website where ppl can type an arbitrary regex in a box dont worry
|
# ? Oct 19, 2012 13:29 |
|
AAAUUUUUGGGHHHHHHHHHH why aren't you writing this in perl6/c#/ruby/clojure/chicken scheme/delphi/anything but C++/elisp and bind it to ctrl-alt-metal-f-g-6/$MY_FAVOURITE_SHITTY_LANGUAGE write it in scala tho scala is p.cool and totes not my favourite lovely language
|
# ? Oct 19, 2012 13:50 |
|
rotor posted:guys guys guys idk maybe you're just getting old getting older
|
# ? Oct 19, 2012 13:54 |
|
carbon date rotor's posts
|
# ? Oct 19, 2012 13:57 |
|
Nomnom Cookie posted:Using user-supplied regexes opens you to a complexity DoS http://code.google.com/p/re2/
|
# ? Oct 19, 2012 14:22 |
|
vapid cutlery posted:basically anything that's ... compile...d ... is the worst
|
# ? Oct 19, 2012 14:38 |
|
Tiny Bug Child posted:writing software is just a lot more fun in general when you're working against the user this is actually quite true.
|
# ? Oct 19, 2012 22:30 |
|
homercles posted:
you forgot objective c
|
# ? Oct 20, 2012 03:06 |
|
xpath is kinda cool i wonder if there's benchmarks for GDataXML
|
# ? Oct 20, 2012 03:06 |
|
i want a good reason to use xpath. it's neat
|
# ? Oct 20, 2012 03:37 |
|
Zizzyx posted:i want a good reason to use xpath. it's neat whenever i have to scrape a webpage i'm going to use xpath from now on. having something that's aware of the *ml hierarchy is invaluable
|
# ? Oct 20, 2012 03:46 |
|
vapid cutlery posted:whenever i have to scrape a webpage i'm going to use xpath from now on. having something that's aware of the *ml hierarchy is invaluable your posts are on the bottom
|
# ? Oct 20, 2012 04:11 |
|
0xB16B00B5 posted:your posts are on the bottom because i'm so grassroots? thanks
|
# ? Oct 20, 2012 04:13 |
|
youre welcome i appreciate your contributions to yawspaws
|
# ? Oct 20, 2012 04:15 |
|
vapid cutlery posted:whenever i have to scrape a webpage i'm going to use xpath from now on. having something that's aware of the *ml hierarchy is invaluable I wish SO badly I could do this, but unfortunately some huge percentage of HTML is a horrible mess. Probabilistic tree's to the rescue.
|
# ? Oct 20, 2012 04:15 |
|
Meiwaku posted:I wish SO badly I could do this, but unfortunately some huge percentage of HTML is a horrible mess. Probabilistic tree's to the rescue. i think beautifulsoup was a good way to deal with those actually, idk if it's available outside of python though
|
# ? Oct 20, 2012 04:21 |
|
Meiwaku posted:I wish SO badly I could do this, but unfortunately some huge percentage of HTML is a horrible mess. Probabilistic tree's to the rescue. libxml/lxml handled a bunch of these with xpath. it works.
|
# ? Oct 20, 2012 06:06 |
|
tef posted:libxml/lxml handled a bunch of these with xpath. it works. yeah iirc ios includes libxml2 and GDataXML+HTML is built on top of it and it rocks
|
# ? Oct 20, 2012 06:20 |
|
|
# ? Jun 11, 2024 19:44 |
|
i've run into some really bad xpath implementations, but if you find a good one it's hella nice
|
# ? Oct 20, 2012 09:00 |