• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:11
CEST 11:11
KST 18:11
  • 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
[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy18ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book20
Community News
$5,000 WardiTV TLMC tournament - Presented by Monster Energy2GSL CK: More events planned pending crowdfunding3Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage4Weekly Cups (March 23-29): herO takes triple6
StarCraft 2
General
Quebec Clan still alive ? BGE Stara Zagora 2026 cancelled Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win Rongyi Cup S3 - Preview & Info
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) Sparkling Tuna Cup - Weekly Open Tournament GSL CK: More events planned pending crowdfunding $5,000 WardiTV TLMC tournament - Presented by Monster Energy RSL Season 4 announced for March-April
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power Mutation # 518 Radiation Zone
Brood War
General
ASL21 General Discussion so ive been playing broodwar for a week straight. BW General Discussion Gypsy to Korea Pros React To: JaeDong vs Queen
Tourneys
Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro24 Group F [BSL22] RO32 Group B - Sunday 21:00 CEST
Strategy
Fighting Spirit mining rates Muta micro map competition What's the deal with APM & what's its true value Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game Nintendo Switch Thread Darkest Dungeon
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread The China Politics Thread European Politico-economics QA Mega-thread Trading/Investing Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How Streamers Inspire Gamers…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
StarCraft improvement
iopq
Electronics
mantequilla
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2119 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
Hyrule19202 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
Poland17719 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
Next event in 50m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft665
Nina 148
StarCraft: Brood War
Hyuk 891
Larva 245
Bisu 160
Shine 144
Dewaltoss 123
PianO 117
scan(afreeca) 103
sSak 66
HiyA 63
EffOrt 57
[ Show more ]
Shinee 38
Hm[arnc] 36
yabsab 34
hero 30
ggaemo 25
NotJumperer 18
NaDa 15
Sacsri 13
IntoTheRainbow 7
Dota 2
XaKoH 777
XcaliburYe143
Fuzer 110
NeuroSwarm101
League of Legends
JimRising 520
Counter-Strike
allub251
Super Smash Bros
Westballz49
Other Games
gofns11985
summit1g10968
singsing749
Happy422
C9.Mang0404
Hui .140
Organizations
Other Games
gamesdonequick789
BasetradeTV178
StarCraft: Brood War
lovetv 16
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Adnapsc2 11
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos2571
Upcoming Events
CranKy Ducklings
50m
WardiTV Team League
1h 50m
uThermal 2v2 Circuit
5h 50m
IPSL
6h 50m
Hawk vs TBD
StRyKeR vs TBD
BSL
9h 50m
n0maD vs perroflaco
TerrOr vs ZZZero
MadiNho vs WolFix
DragOn vs LancerX
Sparkling Tuna Cup
1d
WardiTV Team League
1d 1h
OSC
1d 3h
BSL
1d 9h
Sterling vs Azhi_Dahaki
Napoleon vs Mazur
Jimin vs Nesh
spx vs Strudel
IPSL
1d 9h
Artosis vs TBD
Napoleon vs TBD
[ Show More ]
Replay Cast
1d 23h
Wardi Open
2 days
Afreeca Starleague
2 days
Soma vs YSC
Sharp vs sSak
Afreeca Starleague
3 days
Snow vs PianO
hero vs Rain
GSL
3 days
Replay Cast
3 days
Kung Fu Cup
4 days
The PondCast
5 days
Escore
6 days
Korean StarCraft League
6 days
Liquipedia Results

Completed

Escore Tournament S2: W2
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
WardiTV TLMC #16
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
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.