• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:29
CEST 12:29
KST 19: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
[ASL22] Ro4 Preview: Mirror Mirror5[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5[ASL22] Ro16 Preview: Rough Waters10
Community News
Rollback Netcode in Brood War445.0.17 Patch Notes - October 7, 202621Weekly Cups Results (Sep 28-Oct 4)0SC4ALL: II SC2 Complete Invited Player Lineup10StarCraft II 5.0.17 PTR Patch Notes (Sept 30, 2026)78
StarCraft 2
General
5.0.17 Patch Notes - October 7, 2026 [Old] StarCraft 3 Reportedly in Development StarCraft II 5.0.17 PTR Patch Notes (Sept 30, 2026) How do you feel about the mass reverts in the 5.0.17 PTR? Weekly Cups Results (Sep 28-Oct 4)
Tourneys
ScienceCraft (October 24-25) - Live Event RSL 2026 Offline Finals LCQ Sign-Ups Stellar Fest TWO the Moon (Dec 16-20) ISSL (IntoTheTV x SOOP SC2 League): Premier Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[M] (2) Sweltering Sands [M] (2) Frigid Storage
External Content
Mutation # 546 Catch the Train The PondCast: SC2 News & Results Mutation # 545 And Drops and Rifts Mutation # 544 Double Trouble
Brood War
General
TL Sidebar missing streams BGH Auto Balance -> http://bghmmr.eu/ Rollback Netcode in Brood War [ASL22] Ro4 Preview: Mirror Mirror Bot on ladder
Tourneys
[ASL22] Semifinal B [ASL22] Semifinal A [Megathread] Daily Proleagues [ASL22] Ro8 Day 4
Strategy
Simple Questions, Simple Answers Cliff Jump Revisited (1 in a 1000 strategy) Replay Review Process - What do you do?
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Warcraft III: The Frozen Throne Stormgate/Frost Giant Megathread Total Annihilation Zero
Dota 2
Dota 2 Champions League Season 3 Begins April 25! Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Artificial Intelligence Thread Canadian Politics Mega-thread
Fan Clubs
Serral Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Diablo Animated Series on Netflix
Sports
TeamLiquid Health and Fitness Initiative For 2023 Football (Soccer) Thread MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Escaping Into Video Games: G…
TrAiDoS
38 yo Retired SWE loo…
PurE)Rabbit-SF
Can Bots Beat Pros?? Starcr…
namkraft
[meme] I finally understa…
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 9332 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
Hyrule19260 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
Poland17850 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
Big Brain Bouts
19:00
#129
Rex vs INexorable
GgMaChine vs HeRoMaRinE
Reynor vs herO
RotterdaM459
IndyStarCraft 95
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 459
Lowko257
IndyStarCraft 69
MindelVK 11
StarCraft: Brood War
Free 4874
Stork 2418
Horang2 466
Soulkey 367
Jaedong 344
Larva 268
Zeus 255
Soma 246
Mini 227
BeSt 208
[ Show more ]
sorry 102
Mind 79
Last 67
Hyun 63
Pusan 62
ZerO 60
Sexy 48
Shinee 34
soO 32
scan(afreeca) 24
ajuk12(nOOB) 17
Sacsri 10
zelot 8
Dota 2
XcaliburYe322
canceldota60
League of Legends
JimRising 462
Other Games
gofns33475
singsing2057
Coldzera 704
Happy317
byalli270
Pyrionflax210
ZerO(Twitch)11
Organizations
Other Games
BasetradeTV217
[ Show 13 non-featured ]
StarCraft 2
• LUISG 31
• StrangeGG 14
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV313
• lizZardDota2221
League of Legends
• Jankos3264
Upcoming Events
Online Event
1h 31m
AI Arena Tournament
6h 31m
BSL: Ladder Tournament
8h 31m
Sparkling Tuna Cup
23h 31m
Patches Events
1d 4h
BSL Open Qualifier
1d 8h
BSL Open Qualifier
1d 8h
OSC
2 days
WardiTV Weekly
3 days
PiGosaur Cup
3 days
[ Show More ]
The PondCast
4 days
Online Event
6 days
Korean StarCraft League
6 days
Afreeca Starleague
6 days
Rush vs Soulkey
CranKy Ducklings
6 days
Liquipedia Results

Completed

Acropolis #5 - GSB
Blizzard Classic Cup 2026
Copium Cup

Ongoing

ASL Season 22
Super Anchor Qualifying S3
Acropolis #5
HCC Season 3
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026

Upcoming

Acropolis #5 - GSC
BSL Season 23
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
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.