[QUOTE=xAustechx;25079390]Will do Ryan, will do. And thanks for the advice, I really do use it. Before the lights were just circles, but some recommended to make them better so now they're dynamic.
But I will try to come up with creative ideas. Thanks for the support. :)[/QUOTE]
And have you thought about having sprites instead of using circles?
Made the most boring game of pong ever, computer never looses
{
if bally > paddley then
move paddle up
else
move paddle down
}
next step is to make it more realistic
Even better:
paddleY = ballY - (paddleHeight/2)
Super smart AI amirite?
[QUOTE=Chris220;25090134]Even better:
paddleY = ballY - (paddleHeight/2)
Super smart AI amirite?[/QUOTE]
I thought setting it directly was even more unfair ,
and yeah is pretty dumb, but all A.I starts off as dumb, now I have it only moving when the ball is coming towards it
I'm trying to parse some HTML, but once again regular expression aren't working how I expect them to work.
[cpp]
Pattern p = Pattern.compile("<TD.*?>(.+?)</TD>");
Matcher m = p.matcher(s);
if (m.find()) {
//Never goes here
} else {
//Always goes here
}[/cpp]
s is this:
[code]<TR><TD width="50%" nowrap=1><font size="2" face="Arial">E1</font> </TD><TD width="50%" nowrap=1><font size="2" face="Arial">HO</font> </TD></TR><TR><TD width="50%" nowrap=1><font size="2" face="Arial">5ADV</font> </TD><TD width="50%" nowrap=1><font size="2" face="Arial">1)</font> </TD></TR>[/code]
Through trial&error I found out that for some reason it always stops when it hits "E1".
[QUOTE=Robber;25090723]I'm trying to parse some HTML, but once again regular expression aren't working how I expect them to work.
[cpp]
Pattern p = Pattern.compile("<TD.*?>(.+?)</TD>");
Matcher m = p.matcher(s);
if (m.find()) {
//Never goes here
} else {
//Always goes here
}[/cpp]
s is this:
[code]<TR><TD width="50%" nowrap=1><font size="2" face="Arial">E1</font> </TD><TD width="50%" nowrap=1><font size="2" face="Arial">HO</font> </TD></TR><TR><TD width="50%" nowrap=1><font size="2" face="Arial">5ADV</font> </TD><TD width="50%" nowrap=1><font size="2" face="Arial">1)</font> </TD></TR>[/code]
Through trial&error I found out that for some reason it always stops when it hits "E1".[/QUOTE]
*Ahem* [url]http://stackoverflow.com/q/1732348/13395[/url]
*Ahem*
[quote]While it is true that asking regexes to parse arbitrary HTML is like asking Paris Hilton to write an operating system, it's sometimes appropriate to parse a limited, known set of HTML.
If you have a small set of HTML pages that you want to scrape data from and then stuff into a database, regexes might work fine. For example, I recently wanted to get the names, parties, and districts of Australian federal Representatives, which I got off of the Parliament's Web site. This was a limited, one-time job.
Regexes worked just fine for me, and were very fast to set up.[/quote]
[QUOTE=Robber;25090847]*Ahem*[/QUOTE]
a mere glimpse of the world of reg​ex parsers for HTML will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro********ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂********̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝
I'm not generally parsing HTML. I'm accessing the data inside a machine generated file which happens to be formatted in HTML.
I think my regex is correct. Can someone tell me if I'm wrong or if it's a bug in the regex engine?
Oh and how would you access data in tons of tables in a HTML table (:suicide:) without a combination of regex and indexOfs?
[QUOTE=arienh4;25090901]a mere glimpse of the world of reg​ex parsers for HTML will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro********ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂********̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝[/QUOTE]
Arien, I...
I am confuse.
[QUOTE=arienh4;25090901]a mere glimpse of the world of reg​ex parsers for HTML will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro********ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂********̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝[/QUOTE]
Cthulhu could totally beat up Zalgo in a fight.
[QUOTE=Robber;25090976]I'm not generally parsing HTML. I'm accessing the data inside a machine generated file which happens to be formatted in HTML.
I think my regex is correct. Can someone tell me if I'm wrong or if it's a bug in the regex engine?
Oh and how would you access data in tons of tables in a HTML table (:suicide:) without a combination of regex and indexOfs?[/QUOTE]
To access data in HTML tables you could just copy it from your browser to some editor like notepad. Then you'll still have to parse it somehow, buts it's easier then.
[QUOTE=Chris220;25091124]Arien, I...
I am confuse.[/QUOTE]
[url=http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454]The very same link[/url].
On an unrelated note, my post got a perfect postcount.
[QUOTE=arienh4;25090901]a mere glimpse of the world of reg​ex parsers for HTML will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro********ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂********̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝[/QUOTE]
Haha. Awesome. Rating artistic.
Since nobody could help me I just did it myself using a few indexOfs and it's working :buddy:
[IMG_thumb]http://i53.tinypic.com/258828j.png[/IMG_thumb]
[QUOTE=Robber;25091664]Since nobody could help me I just did it myself using a few indexOfs and it's working :buddy:
[IMG_thumb]http://i53.tinypic.com/258828j.png[/IMG_thumb][/QUOTE]
The answer was to not use regexes. There's a reason the answer I quoted is at the top. (Not just because it's hilarious)
[QUOTE=Richy19;25090057]And have you thought about having sprites instead of using circles?[/QUOTE]
Yes, but unfortunately I can't sprite at all so I have to use the circles for now. :(
[QUOTE=arienh4;25091710]The answer was to not use regexes. There's a reason the answer I quoted is at the top. (Not just because it's hilarious)[/QUOTE]
In theory regexes would have been a lot easier. It's just that there was a small problem where it stopped searching for no reason.
[QUOTE=Robber;25092074]In theory regexes would have been a lot easier. It's just that there was a small problem where it stopped searching for no reason.[/QUOTE]
Easier isn't better. In this case, easier is really really bad.
javax.xml?
Don't you just hate it when something is working fine, then you spot a bug in the code, fix it, run the program again to test it and everything has completely broken.
Sounds like the wonderful work of an optimising (and in this case, fixing), compiler!
No posts in 2 hours? :o
Content:
[img]http://dl.dropbox.com/u/286964/TuneTiles/RandomTiles.jpg[/img]
Programmable tools - In this case a spray can that does random colours :D
Isn't it great when you can get an idea implemented in 10 minutes or less.
Also getting sick of having to use "Color" in code and "Colour" in everything else. I was in my weekly english class and nearly found myself writing "Color"
I wrote a function for calculating the intersection point of the line (d, e) and the plane (a, b, c) in 3D.
[code]
function LineXPlane3(a, b, c, d, e: TVec3): TVec3;
var
d1, d2, d3, d4, t: single;
begin
d1 := ((e.z - a.z)*(b.y - a.y) - (e.y - a.y)*(b.z - a.z)) *
((a.x - c.x)*(b.y - a.y) - (a.y - c.y)*(b.x - a.x));
d2 := ((e.y - a.y)*(b.x - a.x) - (e.x - a.x)*(b.y - a.y)) *
((a.y - c.y)*(b.z - a.z) - (a.z - c.z)*(b.y - a.y));
d3 := ((d.y - e.y)*(b.x - a.x) - (d.x - e.x)*(b.y - a.y)) *
((a.y - c.y)*(b.z - a.z) - (a.z - c.z)*(b.y - a.y));
d4 := ((d.z - e.z)*(b.y - a.y) - (d.y - e.y)*(b.z - a.z)) *
((a.x - c.x)*(b.y - a.y) - (a.y - c.y)*(b.x - a.x));
t := (d1 - d2)/(d3 - d4);
result.x := e.x + t*(d.x - e.x);
result.y := e.y + t*(d.y - e.y);
result.z := e.z + t*(d.z - e.z);
end;
[/code]
Goddamn it was tedious to solve it.
[QUOTE=Tezzanator92;25096268]No posts in 2 hours? :o
Content:
[img]http://dl.dropbox.com/u/286964/TuneTiles/RandomTiles.jpg[/img]
Programmable tools - In this case a spray can that does random colours :D
Isn't it great when you can get an idea implemented in 10 minutes or less.
Also getting sick of having to use "Color" in code and "Colour" in everything else. I was in my weekly english class and nearly found myself writing "Color"[/QUOTE]
I think everyone was in the competition or something is what I was doing for that time anyway
[QUOTE=ThePuska;25096436]I wrote a function for calculating the intersection point of the line (d, e) and the plane (a, b, c) in 3D.
Goddamn it was tedious to solve it.[/QUOTE]
I know what you're talking about.
Took me 2 days to figure out how to put line intersection from paper to a function...
I can only imagine how hard this was.
[QUOTE=thomasfn;25093391]Don't you just hate it when something is working fine, then you spot a bug in the code, fix it, run the program again to test it and everything has completely broken.[/QUOTE]
That's what unit tests are for.
[QUOTE=Ortzinator;25097168]That's what unit tests are for.[/QUOTE]
Don't you hate it when you can't be bothered writing unit tests and then you introduce a bug that turns out to be in the exact opposite place that you think it might be?
Yeah, don't you hate it when programmers have 20/20 hindsight?
What would be the cheapest Mac I could get (preferably used) for programming iPod Touch/iPhone apps?
Sorry, you need to Log In to post a reply to this thread.