• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:35
CEST 12:35
KST 19:35
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Weekly Cups (June 30 - July 6): Classic Doubles0[BSL20] Non-Korean Championship 4x BSL + 4x China7Flash Announces Hiatus From ASL63Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Weekly Cups (June 23-29): Reynor in world title form?
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
ASL20 Preliminary Maps SC uni coach streams logging into betting site Player “Jedi” cheat on CSL Flash Announces Hiatus From ASL BW General Discussion
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [BSL20] Non-Korean Championship 4x BSL + 4x China CSL Xiamen International Invitational The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025! Russo-Ukrainian War Thread
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 697 users

The Big Programming Thread - Page 123

Forum Index > General Forum
Post a Reply
Prev 1 121 122 123 124 125 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
kingcoyote
Profile Blog Joined May 2010
United States546 Posts
March 09 2012 05:33 GMT
#2441
On March 07 2012 20:17 Fryght wrote:
Show nested quote +
On March 07 2012 10:38 tec27 wrote:
On March 07 2012 01:13 supereddie wrote:
I never said anything about AJAX (or polling) - using this with a game is not a good idea. server-sent events however, are viable in my opinion (and part of the html5 'standard').

I think streaming is possible, as long a you have a suitable protocol (like rtp, rtsp, mms) and the browser supports the codec.

WebSockets tend to be better for games, since it allows for bi-directional communicatiton, although its less well supported and a tad harder to set up on certain platforms. Still, http://socket.io/ is a really nice library that makes utilizing WebSockets pretty painless (and has server components for a bunch of languages).


Yeah, I've looked into WebSockets, but a while back there was little to no support across the browser boards. Really hope they would get everyone in line. But CSS3 makes very skeptical. I mean, CSS3 is not exactly rocket science and has been around quite long already, yet there is no standard still and we have browser specific implementations *shudder*


I've used WebSockets and the socket.io library pretty smoothly before. You cut out some browsers due to incompatibility, but that can actually be a good thing at times. It frees up what you can do in other regards. The same can be said about canvas. Does IE7 support <insert functionality here>? It doesn't matter because it doesn't support the entire canvas object and so it's a moot point.

Yeah, you lose some potential users, but unless your Zynga, your target audience is probably net savvy enough to be running a pretty up to date browser and so you don't really lose out that much.
targ
Profile Blog Joined December 2010
Malaysia445 Posts
March 09 2012 18:13 GMT
#2442
Sorry guys, I'm going to ask something slightly off topic, but given the concentration of programmers here I thought it might be a good place to ask.

I did finance in college but somehow got into the IT industry after that. Since the systems I work with require occasional writing of scripts (which are not done by me at the moment), I think learning some programming skills would be good so that I can do it, and from what I see I find it quite interesting. I've been working on CodeAcademy a bit.

The question is: which course should I do? I have two choices. One is an online diploma course in Information technology, comprising of the following modules:
C Programming
Object Oriented Analysis & Design
Mathematics for Computing
Computer and Information Processing
Project: Web Publishing with HTML
Database Design and management
Essentials of Networking and Network Security

Drawbacks is it will all be done online, except for the exams for which I will go to the center.

The other option is I just go to a local training center for a Java course then sit for the Sun Java certifications.

I do feel that I want a formal cert because in my part of the world, certs count for more in terms of getting a job I think, so learning on my own is a good idea, but perhaps make it harder to prove my skills to employers.

So I'm not sure which option to take.
http://billyfoong.blogspot.com/ my other opinions are here
tofucake
Profile Blog Joined October 2009
Hyrule19031 Posts
March 09 2012 18:31 GMT
#2443
The first one. Learning a language and getting certs is great and all, but learning design practices and the theories and general methodologies behind programming is by far the better option.
Liquipediaasante sana squash banana
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
March 09 2012 18:37 GMT
#2444
The first one if you want to go deeper and plan on being a "full programmer".

The second one if you want to "just make stuff that will help me to automate some trivial thing".
"When the geyser died, a probe came out" - SirJolt
Sluggy
Profile Joined June 2010
United States128 Posts
Last Edited: 2012-03-10 06:12:53
March 09 2012 18:52 GMT
#2445
On March 10 2012 03:13 targ wrote:
Sorry guys, I'm going to ask something slightly off topic, but given the concentration of programmers here I thought it might be a good place to ask.

I did finance in college but somehow got into the IT industry after that. Since the systems I work with require occasional writing of scripts (which are not done by me at the moment), I think learning some programming skills would be good so that I can do it, and from what I see I find it quite interesting. I've been working on CodeAcademy a bit.

The question is: which course should I do? I have two choices. One is an online diploma course in Information technology, comprising of the following modules:
C Programming
Object Oriented Analysis & Design
Mathematics for Computing
Computer and Information Processing
Project: Web Publishing with HTML
Database Design and management
Essentials of Networking and Network Security

Drawbacks is it will all be done online, except for the exams for which I will go to the center.

The other option is I just go to a local training center for a Java course then sit for the Sun Java certifications.

I do feel that I want a formal cert because in my part of the world, certs count for more in terms of getting a job I think, so learning on my own is a good idea, but perhaps make it harder to prove my skills to employers.

So I'm not sure which option to take.


If you're motivated you can replace the stuff in the 1st courses with good books/online resources. Employers won't care about the online course completion. People can get through without putting in the extra work necessary to truly grasp the point of it all. This is true even for b.s. in computer science. The value of such accomplishments has diminished over time. In the long run it's all about what you are capable of.

C Programming: I would look at the syllabus if it's available. If you're learning dynamic memory management/pointers then that course will provide something that the java course won't. Otherwise there will be a lot of overlap (looping structures/conditionals/stuff you learned on code academy..) and you will feel it's a waste of time. Even then, things like pointers are difficult to work with at first, but if you can get a general understanding of them that's all you need. From the sounds of it you'll never need to touch them in the line of work you're looking for, so the general understanding can be learned on your own.

Object Oriented Analysis & Design: After you take a java course just get the book Headfirst Design Patterns (OReilly) and it will cover more than that class will, and it will do a better job.

Mathematics for computing: Khan academy

Computer and Information Processing: probably useless, would have to see syllabus

Web publishing with html: Chances are your instructor will dump a framework on you that you'll never use. HTML is very easy to learn on your own.

Database Design: http://www.amazon.com/Sams-Teach-Yourself-SQL-Minutes/dp/0672325675. That class will probably offer 1 lecture on actual relational database design at the end of the course, you can learn about database interaction way better from that book (just pick a dbms: http://dbconvert.com/overview.php ). After that you'll be prepared to learn as you do stuff or take a more advanced course somewhere if required.

Essentials of networking and network security: There is a lot of overhead to this so an introductory class might be helpful, still plenty of other resources to learn from.


I'd do option B
Mordanis
Profile Blog Joined January 2011
United States893 Posts
March 09 2012 22:21 GMT
#2446
Hi, I am thinking about learning to jump into programming, but I have no idea where to start. I am hoping to work either as a physicist/astronomer or something in economics ( hopefully with a firm, not a school). First, what language should I start working with and second, how do you start from scratch? Also I am planning on taking a CS class next semester, or maybe during the summer :D.
I love the smell of napalm in the morning... it smells like... victory. -_^ Favorite SC2 match ->Liquid`HerO vs. SlayerS CranK g.1 @MLG Summer Championship
Frigo
Profile Joined August 2009
Hungary1023 Posts
Last Edited: 2012-03-09 23:01:58
March 09 2012 22:59 GMT
#2447
I'd opt for option A. Programming is not just the familiarity of a particular programming language, it needs a wide range of skills and knowledge*. More than likely you do not yet have these. Java on the other hand, is very easy to pick up, and certifications are near useless.

*: For the record I'm employed as a Java programmer, and I barely knew Java before joining. We mainly do maintenance work like writing and fixing tests, fixing and refactoring production code. Basic knowledge of linux, regular expressions, revision control, Ant build scripts, editors, file managers, et cetera are a must. Hobby projects, team work experience, knowledge of Scrum, Agile, XP are huge advantages.

Related: http://www.codinghorror.com/blog/2012/03/how-to-hire-a-programmer.html
http://www.fimfiction.net/user/Treasure_Chest
Fryght
Profile Joined August 2010
Netherlands254 Posts
Last Edited: 2012-03-10 02:22:45
March 10 2012 02:18 GMT
#2448
On March 09 2012 14:33 visual77 wrote:
Show nested quote +
On March 07 2012 20:17 Fryght wrote:
On March 07 2012 10:38 tec27 wrote:
On March 07 2012 01:13 supereddie wrote:
I never said anything about AJAX (or polling) - using this with a game is not a good idea. server-sent events however, are viable in my opinion (and part of the html5 'standard').

I think streaming is possible, as long a you have a suitable protocol (like rtp, rtsp, mms) and the browser supports the codec.

WebSockets tend to be better for games, since it allows for bi-directional communicatiton, although its less well supported and a tad harder to set up on certain platforms. Still, http://socket.io/ is a really nice library that makes utilizing WebSockets pretty painless (and has server components for a bunch of languages).


Yeah, I've looked into WebSockets, but a while back there was little to no support across the browser boards. Really hope they would get everyone in line. But CSS3 makes very skeptical. I mean, CSS3 is not exactly rocket science and has been around quite long already, yet there is no standard still and we have browser specific implementations *shudder*


I've used WebSockets and the socket.io library pretty smoothly before. You cut out some browsers due to incompatibility, but that can actually be a good thing at times. It frees up what you can do in other regards. The same can be said about canvas. Does IE7 support <insert functionality here>? It doesn't matter because it doesn't support the entire canvas object and so it's a moot point.

Yeah, you lose some potential users, but unless your Zynga, your target audience is probably net savvy enough to be running a pretty up to date browser and so you don't really lose out that much.


Differences between Chrome and Firefox are already pretty big. A lot of support is 'experimental'. Bit too volatile for my taste.

As for the guy asking about what course to take, I'd go with the online one. Like others have said, Java can be picked up fairly easily if you have understanding of programming concepts. Certifications are probably only going to be considered a plus if you are going to work specifically in the language you got the certification for. Experience is usually valued much more, however.

Another option would be to buy a few O'Reilly books on a subject you're interested in. Lynda.com has some ok entry level stuff to get you started if you are looking for specifics.

Mostly it just depends on what area you are looking at to get into. But as a general rule, the language you are using is merely the tool. Without knowing how to plan and then how to build an house, having a hammer is not going to help you much. But having the hammer, you can keep whacking on things until you figure out how to build the house :D
But then again, at a professional level "Hey, I gave it a shot!" is not really acceptable, so knowing how to properly plan and structure things is the most important, I'd say :p
targ
Profile Blog Joined December 2010
Malaysia445 Posts
March 10 2012 08:42 GMT
#2449
Thanks for the advice guys, I see most of the responses is for Option A for a better grounding, though thanks alot to the guy for Option B who listed out all those resources, that will be very helpful for me. I'm going to give a bit more thought to the options based on my current schedule.
http://billyfoong.blogspot.com/ my other opinions are here
Sluggy
Profile Joined June 2010
United States128 Posts
Last Edited: 2012-03-11 04:10:34
March 11 2012 04:01 GMT
#2450
edit: Forgot to mention this is C# 4.0

What is wrong with this regex?

The program input is coming from an html file. I am reading that html file line by line and dumping that in to a StringWriter. The StringWriter is then passing the body of text as a single string (THE INCOMING TEXT HAS \r\n's (NOT SHOWN) after each <br> tag IF THAT IS RELEVANT):


<!-- saved from url=(0126)http://www.wunderground.com/history/airport/KMTO/2012/3/9/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1 -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>.....truncated<br>
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00<br>
1:53 AM,35.1,26.1,70,30.40,10.0,West,8.1,-,N/A,,Clear,270,2012-03-09 07:53:00<br>
2:53 AM,36.0,25.0,64,30.39,10.0,West,9.2,-,N/A,,Clear,260,2012-03-09 08:53:00<br>
3:53 AM,36.0,25.0,64,30.39,10.0,WSW,6.9,-,N/A,,Clear,250,2012-03-09 09:53:00<br>
4:53 AM,36.0,25.0,64,30.42,10.0,West,10.4,-,N/A,,Clear,270,2012-03-09 10:53:00<br>
5:53 AM,34.0,26.1,73,30.44,10.0,WNW,11.5,-,N/A,,Clear,290,2012-03-09 11:53:00<br>
6:53 AM,34.0,26.1,73,30.45,10.0,WNW,15.0,-,N/A,,Clear,300,2012-03-09 12:53:00<br>
7:53 AM,36.0,26.1,67,30.49,10.0,NW,18.4,-,N/A,,Clear,320,2012-03-09 13:53:00<br>
8:53 AM,37.0,25.0,62,30.51,10.0,NNW,18.4,-,N/A,,Clear,330,2012-03-09 14:53:00<br>
10:53 AM,41.0,23.0,49,30.54,10.0,NW,17.3,21.9,N/A,,Clear,320,2012-03-09 16:53:00<br>
11:53 AM,43.0,19.9,40,30.54,10.0,NNW,11.5,23.0,N/A,,Clear,340,2012-03-09 17:53:00<br>
12:53 PM,44.1,19.9,38,30.52,10.0,North,12.7,23.0,N/A,,Clear,350,2012-03-09 18:53:00<br>
1:53 PM,45.0,21.0,39,30.51,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 19:53:00<br>
2:53 PM,46.0,21.9,39,30.50,10.0,North,-9999.0,-,N/A,,Clear,0,2012-03-09 20:53:00<br>
3:53 PM,45.0,21.0,39,30.50,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 21:53:00<br>
4:53 PM,44.1,19.9,38,30.50,10.0,North,10.4,-,N/A,,Clear,360,2012-03-09 22:53:00<br>
5:53 PM,39.0,21.0,49,30.51,10.0,North,6.9,-,N/A,,Clear,360,2012-03-09 23:53:00<br>
6:53 PM,36.0,21.0,55,30.52,10.0,North,5.8,-,N/A,,Clear,350,2012-03-10 00:53:00<br>
7:53 PM,35.1,21.9,59,30.53,10.0,North,4.6,-,N/A,,Clear,10,2012-03-10 01:53:00<br>
8:53 PM,30.9,21.0,67,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 02:53:00<br>
9:53 PM,32.0,19.9,61,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 03:53:00<br>
10:53 PM,33.1,16.0,50,30.52,10.0,East,3.5,-,N/A,,Clear,80,2012-03-10 04:53:00<br>
11:53 PM,33.1,15.1,48,30.52,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 05:53:00<br>
</body></html>


I wrote a regular expression that is intended to grab each of the timestamps up until the line break, but it only gets the first..

Relevant Code:


private static void ProcessBody(string text)
{
Regex CONTENT = new Regex(@"(?<content>\d{1,2}:\d{1,2} [AP]M.+)<br>", RegexOptions.Multiline);;

if (text != string.Empty)
{
Match contentMatch = CONTENT.Match(text);

if (contentMatch.Success)
{
Console.WriteLine(contentMatch.Groups["content"].Captures.Count);
Console.WriteLine(contentMatch.Groups["content"].Captures[0]);
}
}
}



The output of this program is:

1
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00

Any ideas of how to get it to capture all of them?
Fryght
Profile Joined August 2010
Netherlands254 Posts
Last Edited: 2012-03-11 13:13:01
March 11 2012 13:04 GMT
#2451
http://www.dotnetperls.com/regex-matches

// Program that uses Regex.Matches method [C#]

using System;
using System.Text.RegularExpressions;

class Program
{
static void Main()
{
// Input string.
const string value = @"said shed see spear spread super";

// Get a collection of matches.
MatchCollection matches = Regex.Matches(value, @"s\w+d");

// Use foreach loop.
foreach (Match match in matches)
{
foreach (Capture capture in match.Captures)
{
Console.WriteLine("Index={0}, Value={1}", capture.Index, capture.Value);
}
}
}
}

// Output

// Index=0, Value=said
// Index=5, Value=shed
// Index=20, Value=spread
IMlemon
Profile Blog Joined May 2008
Lithuania296 Posts
March 11 2012 15:24 GMT
#2452
On March 11 2012 13:01 Sluggy wrote:
edit: Forgot to mention this is C# 4.0

What is wrong with this regex?

The program input is coming from an html file. I am reading that html file line by line and dumping that in to a StringWriter. The StringWriter is then passing the body of text as a single string (THE INCOMING TEXT HAS \r\n's (NOT SHOWN) after each <br> tag IF THAT IS RELEVANT):


<!-- saved from url=(0126)http://www.wunderground.com/history/airport/KMTO/2012/3/9/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1 -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>.....truncated<br>
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00<br>
1:53 AM,35.1,26.1,70,30.40,10.0,West,8.1,-,N/A,,Clear,270,2012-03-09 07:53:00<br>
2:53 AM,36.0,25.0,64,30.39,10.0,West,9.2,-,N/A,,Clear,260,2012-03-09 08:53:00<br>
3:53 AM,36.0,25.0,64,30.39,10.0,WSW,6.9,-,N/A,,Clear,250,2012-03-09 09:53:00<br>
4:53 AM,36.0,25.0,64,30.42,10.0,West,10.4,-,N/A,,Clear,270,2012-03-09 10:53:00<br>
5:53 AM,34.0,26.1,73,30.44,10.0,WNW,11.5,-,N/A,,Clear,290,2012-03-09 11:53:00<br>
6:53 AM,34.0,26.1,73,30.45,10.0,WNW,15.0,-,N/A,,Clear,300,2012-03-09 12:53:00<br>
7:53 AM,36.0,26.1,67,30.49,10.0,NW,18.4,-,N/A,,Clear,320,2012-03-09 13:53:00<br>
8:53 AM,37.0,25.0,62,30.51,10.0,NNW,18.4,-,N/A,,Clear,330,2012-03-09 14:53:00<br>
10:53 AM,41.0,23.0,49,30.54,10.0,NW,17.3,21.9,N/A,,Clear,320,2012-03-09 16:53:00<br>
11:53 AM,43.0,19.9,40,30.54,10.0,NNW,11.5,23.0,N/A,,Clear,340,2012-03-09 17:53:00<br>
12:53 PM,44.1,19.9,38,30.52,10.0,North,12.7,23.0,N/A,,Clear,350,2012-03-09 18:53:00<br>
1:53 PM,45.0,21.0,39,30.51,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 19:53:00<br>
2:53 PM,46.0,21.9,39,30.50,10.0,North,-9999.0,-,N/A,,Clear,0,2012-03-09 20:53:00<br>
3:53 PM,45.0,21.0,39,30.50,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 21:53:00<br>
4:53 PM,44.1,19.9,38,30.50,10.0,North,10.4,-,N/A,,Clear,360,2012-03-09 22:53:00<br>
5:53 PM,39.0,21.0,49,30.51,10.0,North,6.9,-,N/A,,Clear,360,2012-03-09 23:53:00<br>
6:53 PM,36.0,21.0,55,30.52,10.0,North,5.8,-,N/A,,Clear,350,2012-03-10 00:53:00<br>
7:53 PM,35.1,21.9,59,30.53,10.0,North,4.6,-,N/A,,Clear,10,2012-03-10 01:53:00<br>
8:53 PM,30.9,21.0,67,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 02:53:00<br>
9:53 PM,32.0,19.9,61,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 03:53:00<br>
10:53 PM,33.1,16.0,50,30.52,10.0,East,3.5,-,N/A,,Clear,80,2012-03-10 04:53:00<br>
11:53 PM,33.1,15.1,48,30.52,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 05:53:00<br>
</body></html>


I wrote a regular expression that is intended to grab each of the timestamps up until the line break, but it only gets the first..

Relevant Code:


private static void ProcessBody(string text)
{
Regex CONTENT = new Regex(@"(?<content>\d{1,2}:\d{1,2} [AP]M.+)<br>", RegexOptions.Multiline);;

if (text != string.Empty)
{
Match contentMatch = CONTENT.Match(text);

if (contentMatch.Success)
{
Console.WriteLine(contentMatch.Groups["content"].Captures.Count);
Console.WriteLine(contentMatch.Groups["content"].Captures[0]);
}
}
}



The output of this program is:

1
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00

Any ideas of how to get it to capture all of them?


http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

Use a tool for parsing html instead of regular expressions.
My future's so bright, I gotta wear shades.
Vansetsu
Profile Blog Joined October 2010
United States1454 Posts
March 11 2012 15:58 GMT
#2453
I am not 100% sure, but I believe this is the best place to post this question.

I am very interested in creating an offline, interactive document. Basically something that I can create, link audio to text, pictures ect. The important part is that it is completely function-able and editable offline, and that it works fine when I send it to someone else (i.e. it doesn't loose function-ability do to certain directories changing, simply because it is on another computer.) I think I can do this with a PDF perhaps, but I am not sure. Also, the program used to create this document needs to be some sort of freeware. I don't care if it looks like a webpage from 1998, it just has to function like I stated above.

I haven't written any sort of HTML for many years, so anything with very little or no coding (ie Frontpage) would be very helpful.

Apologies in advance if there is an easy solution for this and I am just behind with the times or HTML.
Only by overcoming many obstacles does a river become - デイヴィ¯\_(ツ)_/¯ド
Sluggy
Profile Joined June 2010
United States128 Posts
March 11 2012 20:01 GMT
#2454
On March 12 2012 00:24 IMlemon wrote:
Show nested quote +
On March 11 2012 13:01 Sluggy wrote:
edit: Forgot to mention this is C# 4.0

What is wrong with this regex?

The program input is coming from an html file. I am reading that html file line by line and dumping that in to a StringWriter. The StringWriter is then passing the body of text as a single string (THE INCOMING TEXT HAS \r\n's (NOT SHOWN) after each <br> tag IF THAT IS RELEVANT):


<!-- saved from url=(0126)http://www.wunderground.com/history/airport/KMTO/2012/3/9/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1 -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>.....truncated<br>
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00<br>
1:53 AM,35.1,26.1,70,30.40,10.0,West,8.1,-,N/A,,Clear,270,2012-03-09 07:53:00<br>
2:53 AM,36.0,25.0,64,30.39,10.0,West,9.2,-,N/A,,Clear,260,2012-03-09 08:53:00<br>
3:53 AM,36.0,25.0,64,30.39,10.0,WSW,6.9,-,N/A,,Clear,250,2012-03-09 09:53:00<br>
4:53 AM,36.0,25.0,64,30.42,10.0,West,10.4,-,N/A,,Clear,270,2012-03-09 10:53:00<br>
5:53 AM,34.0,26.1,73,30.44,10.0,WNW,11.5,-,N/A,,Clear,290,2012-03-09 11:53:00<br>
6:53 AM,34.0,26.1,73,30.45,10.0,WNW,15.0,-,N/A,,Clear,300,2012-03-09 12:53:00<br>
7:53 AM,36.0,26.1,67,30.49,10.0,NW,18.4,-,N/A,,Clear,320,2012-03-09 13:53:00<br>
8:53 AM,37.0,25.0,62,30.51,10.0,NNW,18.4,-,N/A,,Clear,330,2012-03-09 14:53:00<br>
10:53 AM,41.0,23.0,49,30.54,10.0,NW,17.3,21.9,N/A,,Clear,320,2012-03-09 16:53:00<br>
11:53 AM,43.0,19.9,40,30.54,10.0,NNW,11.5,23.0,N/A,,Clear,340,2012-03-09 17:53:00<br>
12:53 PM,44.1,19.9,38,30.52,10.0,North,12.7,23.0,N/A,,Clear,350,2012-03-09 18:53:00<br>
1:53 PM,45.0,21.0,39,30.51,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 19:53:00<br>
2:53 PM,46.0,21.9,39,30.50,10.0,North,-9999.0,-,N/A,,Clear,0,2012-03-09 20:53:00<br>
3:53 PM,45.0,21.0,39,30.50,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 21:53:00<br>
4:53 PM,44.1,19.9,38,30.50,10.0,North,10.4,-,N/A,,Clear,360,2012-03-09 22:53:00<br>
5:53 PM,39.0,21.0,49,30.51,10.0,North,6.9,-,N/A,,Clear,360,2012-03-09 23:53:00<br>
6:53 PM,36.0,21.0,55,30.52,10.0,North,5.8,-,N/A,,Clear,350,2012-03-10 00:53:00<br>
7:53 PM,35.1,21.9,59,30.53,10.0,North,4.6,-,N/A,,Clear,10,2012-03-10 01:53:00<br>
8:53 PM,30.9,21.0,67,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 02:53:00<br>
9:53 PM,32.0,19.9,61,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 03:53:00<br>
10:53 PM,33.1,16.0,50,30.52,10.0,East,3.5,-,N/A,,Clear,80,2012-03-10 04:53:00<br>
11:53 PM,33.1,15.1,48,30.52,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 05:53:00<br>
</body></html>


I wrote a regular expression that is intended to grab each of the timestamps up until the line break, but it only gets the first..

Relevant Code:


private static void ProcessBody(string text)
{
Regex CONTENT = new Regex(@"(?<content>\d{1,2}:\d{1,2} [AP]M.+)<br>", RegexOptions.Multiline);;

if (text != string.Empty)
{
Match contentMatch = CONTENT.Match(text);

if (contentMatch.Success)
{
Console.WriteLine(contentMatch.Groups["content"].Captures.Count);
Console.WriteLine(contentMatch.Groups["content"].Captures[0]);
}
}
}



The output of this program is:

1
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00

Any ideas of how to get it to capture all of them?


http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

Use a tool for parsing html instead of regular expressions.


Your comment lead me to check out HtmlAgilityPack which helped do what I needed here and greatly simplify another portion of the program (pulling stuff directly from the site), so thanks for that

That being said, I know html and regex don't always go well together, but I think for this example getting 23 captures out of that should be possible. I don't think it's the <br> tags that are breaking the code. So if someone could either explain the details of why I can't do this simple task with regex, or show the proper way, I would appreciate it!.
Days
Profile Joined February 2010
United States219 Posts
March 12 2012 02:00 GMT
#2455
On March 12 2012 10:51 Days wrote:
Hey guys in some desperate need of help for this java programming hw! I have been racking my brains all day with this. The assignment is as follows:

Write a class called Cashier that directs a cashier how to cash goods and give change to customers. The typical cashier operations are as follows:
(a) Cashier clears the cash register machine.
(b) Cashier enters the name and the price of each item in the cash registering machine.
(c) The customer tenders an amount of money to pay for the goods (We assume the amount covers the total).
(d) The cash machine computes:
i. The number of items purchased
ii. The total amount of purchase
iii. The average price of each item
iv. The number of coin denominations that the customer should receive. That is, the number of silver dollars, quarters, dimes, nickels, and cents the customer should receive in turn.

Now I have created a class cashier and a test class cashier, I have also added a GetData class. The problem lies in the first part of my TestCashier class in which errors compile, shown here:

String name = GetData.getWord(“Enter name of item”);
double price = GetData.getDouble(“Enter price of item”);
c.add(name, price);

name = GetData.getWord(“Enter name of item”);
price = GetData.getDouble(“Enter price of item”);
c.add(name, price);
name = GetData.getWord(“Enter name of item”);
price = GetData.getDouble(“Enter price of item”);
c.add(name, price);

It says that the name and price is already defined in main(java.lang.String[arg])

Please if someone could help me out on this I will love you forever!

We buy things we don't need, with money we don't have, to impress people we don't like.
alwinuz
Profile Joined September 2011
Netherlands77 Posts
March 12 2012 03:21 GMT
#2456
What does the error say? You define a variable with the same name more than one time.
Example of why the error occurs here
Just googled your error BTW, did you do that? An error you don't understand? First step: google it

So you have to make sure you only have the definition of the name variable one time
"String name" <-- you define the 'name' variable here.

Ofcourse same story for variable 'price'.
GL
Days
Profile Joined February 2010
United States219 Posts
March 12 2012 03:29 GMT
#2457
On March 12 2012 12:21 alwinuz wrote:
What does the error say? You define a variable with the same name more than one time.
Example of why the error occurs here
Just googled your error BTW, did you do that? An error you don't understand? First step: google it

So you have to make sure you only have the definition of the name variable one time
"String name" <-- you define the 'name' variable here.

Ofcourse same story for variable 'price'.
GL


I have made sure I only defined the variable once, I don't think that is the problem.
We buy things we don't need, with money we don't have, to impress people we don't like.
Rannasha
Profile Blog Joined August 2010
Netherlands2398 Posts
March 12 2012 08:17 GMT
#2458
Perhaps post the entire code? (As a link to a file or in spoiler-tags, so that it doesn't litter the forums too much) Errors when compiling need not be directly related to the line referenced by the compiler.
Such flammable little insects!
Kentor *
Profile Blog Joined December 2007
United States5784 Posts
Last Edited: 2012-03-12 18:47:59
March 12 2012 18:45 GMT
#2459
On March 12 2012 12:29 Days wrote:
Show nested quote +
On March 12 2012 12:21 alwinuz wrote:
What does the error say? You define a variable with the same name more than one time.
Example of why the error occurs here
Just googled your error BTW, did you do that? An error you don't understand? First step: google it

So you have to make sure you only have the definition of the name variable one time
"String name" <-- you define the 'name' variable here.

Ofcourse same story for variable 'price'.
GL


I have made sure I only defined the variable once, I don't think that is the problem.

post the entire code. and know the difference between defining a variable and declaring a variable. You may not declare a variable twice in the same scope.

the error message should really be you've already declared the variable instead of define. -_-
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2012-03-12 22:14:37
March 12 2012 21:58 GMT
#2460
Might I ask a question about design and theory? We've decided with a couple of buddies to make a simple 2D turn based space combat game. The problem is, it's been ages since I did any real maths/physics and I'm not sure how to approach one thing...

Stuff I need:
1. Ship position - pretty obvious, (x, y) coordinates on a grid.
2. Ship bearing and speed - also obvious, vector originating from ship position.
3. Ship relation to each other - this one is problematic.

What I need:
I must know in which of the 4 90 degrees arcs of a ship is another ship. One way to do it (although I'm not sure if that's the optimal way) would be to get another grid centered on the ship position and rotated 45 degrees. This way, by checking other ship's position on this "personal" grid I'd know in which arc it is (x, y) = front, (-x, y) = left, (x, -y) = right, (-x, -y) = rear. Comparing the vectors will then also give me info if the ships are closing, abeam or moving away in certain arc.

Is there a better way of doing it?
Time is precious. Waste it wisely.
Prev 1 121 122 123 124 125 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 25m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Creator 99
Rex 5
StarCraft: Brood War
Hyuk 759
Pusan 491
Soma 457
Stork 309
Jaedong 205
ZerO 170
Sharp 160
Larva 134
sorry 129
Soulkey 98
[ Show more ]
sSak 98
Shine 65
yabsab 51
Snow 39
Aegong 39
Free 27
zelot 26
JulyZerg 25
Mind 24
IntoTheRainbow 10
ivOry 3
Dota 2
XcaliburYe586
XaKoH 466
syndereN92
League of Legends
singsing182
Counter-Strike
shoxiejesuss675
x6flipin382
allub147
Super Smash Bros
Mew2King215
Other Games
Pyrionflax305
crisheroes265
SortOf152
rGuardiaN45
ZerO(Twitch)16
Organizations
Other Games
gamesdonequick29158
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota2227
League of Legends
• HappyZerGling100
Other Games
• WagamamaTV166
Upcoming Events
Wardi Open
25m
Replay Cast
13h 25m
Sparkling Tuna Cup
23h 25m
WardiTV European League
1d 5h
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 13h
The PondCast
1d 23h
WardiTV European League
2 days
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
2 days
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
[ Show More ]
Replay Cast
3 days
RSL Revival
3 days
Classic vs Cure
FEL
4 days
RSL Revival
4 days
FEL
5 days
FEL
5 days
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
6 days
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.