• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 16:29
CET 22:29
KST 06:29
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
[BSL21] Non-Korean Championship - Starts Jan 100SC2 All-Star Invitational: Jan 17-1819Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3ComeBackTV's documentary on Byun's Career !11
StarCraft 2
General
Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises SC2 All-Star Invitational: Jan 17-18 Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach ComeBackTV's documentary on Byun's Career !
Tourneys
OSC Season 13 World Championship WardiTV Mondays $5,000+ WardiTV 2025 Championship $100 Prize Pool - Winter Warp Gate Masters Showdow Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution Mutation # 503 Fowl Play
Brood War
General
A cwal.gg Extension - Easily keep track of anyone I would like to say something about StarCraft StarCraft & BroodWar Campaign Speedrun Quest BGH Auto Balance -> http://bghmmr.eu/ (UMS) SWITCHEROO *New* /Destination Edit/
Tourneys
SLON Grand Finals – Season 2 [BSL21] Non-Korean Championship - Starts Jan 10 [Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET
Strategy
Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player Fighting Spirit mining rates
Other Games
General Games
Elden Ring Thread General RTS Discussion Thread Nintendo Switch Thread Awesome Games Done Quick 2026! Stormgate/Frost Giant Megathread
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Canadian Politics Mega-thread The Games Industry And ATVI 12 Days of Starcraft
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
National Diversity: A Challe…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 935 users

The Big Programming Thread - Page 123

Forum Index > General Forum
Post a Reply
Prev 1 121 122 123 124 125 1032 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
Hyrule19186 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
Poland17557 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 1032 Next
Please log in or register to reply.
Live Events Refresh
The PiG Daily
21:00
Best Games of SC
Reynor vs Clem
MaxPax vs TBD
SHIN vs TBD
Rogue vs TBD
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 655
PiGStarcraft234
ProTech106
UpATreeSC 83
SC2Nice 33
RushiSC 33
Railgan 30
StarCraft: Brood War
Mini 149
Shuttle 86
firebathero 76
Killer 31
Sexy 22
JYJ 18
yabsab 11
Dota 2
febbydoto18
League of Legends
C9.Mang0231
Counter-Strike
pashabiceps2762
Heroes of the Storm
Liquid`Hasu574
Other Games
Grubby5583
tarik_tv3411
FrodaN2395
Beastyqt1062
B2W.Neo359
fl0m345
mouzStarbuck324
ArmadaUGS145
Livibee108
KnowMe98
IndyStarCraft 85
QueenE66
PPMD32
ZombieGrub30
Organizations
StarCraft 2
angryscii 18
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• kabyraGe 233
• davetesta6
• Kozan
• LaughNgamezSOOP
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• IndyKCrew
StarCraft: Brood War
• Azhi_Dahaki8
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV660
Other Games
• imaqtpie3281
• Shiphtur347
• tFFMrPink 22
Upcoming Events
Korean StarCraft League
5h 31m
OSC
14h 31m
IPSL
19h 31m
Dewalt vs Bonyth
OSC
20h 31m
OSC
1d 14h
uThermal 2v2 Circuit
1d 16h
Replay Cast
2 days
RotterdaM Event
2 days
Patches Events
2 days
OSC
3 days
[ Show More ]
OSC
4 days
OSC
5 days
Liquipedia Results

Completed

C-Race Season 1
WardiTV 2025
META Madness #9

Ongoing

IPSL Winter 2025-26
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 2
Escore Tournament S1: W2
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

CSL 2025 WINTER (S19)
Escore Tournament S1: W3
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
OSC Championship Season 13
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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 © 2026 TLnet. All Rights Reserved.