string-parsing

How would I sort files to directories based on filenames?

I have a huge number of files to sort all named in some terrible convention. Here are some examples: (4)_mr__mcloughlin____.txt 12__sir_john_farr____.txt (b)mr__chope____.txt dame_elaine_kellett-bowman____.txt dr__blackburn______.txt These names are supposed to be a different person (speaker) each. Someone in another IT department ...

How to call split(token) on a string that does not contain the token without causing an error?

I have two types of strings as the IDs of elements in my HTML markup: Dates: "april-23" "march-20" and season names: "springtime" "winter" The dates have a dash separating the month and the day. The seasons are a single word with no other tokens. I want to assign the month or the season to a new variable called: time_of_year ...

How do you get an unsigned long out of a string?

What's the safest and best way to retrieve an unsigned long from a string in C++? I know of a number of possible methods. First, converting a signed long taken from atol. char *myStr; // Initalized to some value somehow. unsigned long n = ((unsigned)atol(myStr)); The obvious problem with this is, what happens when the value stored i...

Programming idiom to parse a string in multiple-passes

I'm working on a Braille translation library, and I need to translate a string of text into braille. I plan to do this in multiple passes, but I need a way to keep track of which parts of the string have been translated and which have not, so I don't retranslate them. I could always create a class which would track the ranges of positi...

How can I get an e-mail address out of a string of key=value pairs?

How can I get some part of string that I need? accountid=xxxxxx type=prem servertime=1256876305 addtime=1185548735 validuntil=1265012019 username=noob directstart=1 protectfiles=0 rsantihack=1 plustrafficmode=1 mirrors= jsconfig=1 [email protected] lots=0 fpoints=6076 ppoints=149 curfiles=38 curspace=3100655714 bodkb=60000000 premkble...

Getting domain in AS3

I know how to get the URL of the page, but how can I extract simply the domain and the domain alone? It must return the same value with or without www, and it must also return the same value regardless of file, with or without trailing slash, etc. So www.domain.com would return domain.com, and domain.com/index.php would return the same...

Code to parse user agent string?

As strange as I find this, I have not been able to find a good PHP function anywhere which will do an intelligent parse of a user agent string? Googled it for about 20 minutes now. I have the string already, I just need something that will chop it up and give me at least browser/ver/os. Know of a good snippet anywhere? ...

Parse hour and AM/PM value from a string - C#

What would be the most effective way to parse the hour and AM/PM value from a string format like "9:00 PM" in C#? Pseudocode: string input = "9:00 PM"; //use algorithm //end result int hour = 9; string AMPM = "PM"; ...

What is a good python parser for a google-like search query?

For some search-based code (in Python), I need to write a query syntax parser that would parse a simple google like query syntax. For example: all of these words "with this phrase" OR that OR this site:within.site filetype:ps from:lastweek As search becomes more an more popular, I expected to be able to easily find a python lib...

How do I extract a substring from a string until the second space is encountered?

i have a string like this: "o1 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467" How do I extract only "o1 1232.5467"? The number of characters to be extracted are not the same always.. hence I want to extract until the second space is encountered. ...

how can I parse and group/do stats on user agent strings?

I have a database that has the various user-agent strings of visitors to our site. I'd like to do a 'survey' of them to see what browsers our users are using, so that I can know what features I can use in future development. Is there a tool to parse and run statistics on user-agent strings, or a bunch of strings like this? Ideally, I'...

How Do I Pull Info from String

I am trying to pull dynamics from a load that I run using bash. I have gotten to a point where I get the string I want, now from this I want to pull certain information that can vary. The string that gets returned is as follows: Records: 2910 Deleted: 0 Skipped: 0 Warnings: 0 Each of the number can and will vary in length, but the o...

Effective way of String splitting

I have a completed string like this N:Pay in Cash++RGI:40++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP:~~ N:ERedemption++RGI:42++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD...

strip version from package name using Bash

hi, I'm trying to strip the version out of a package name using only Bash. I have one solution but I don't think that's the best one available, so I'd like to know if there's a better way to do it. by better I mean cleaner, easier to understand. suppose I have the string "my-program-1.0" and I want only "my-program". my current solutio...

Win32: How to convert string to a date?

In Windows, i want to parse a string as a date using an exact format string. For example, given the string "6/12/2010" and the format: "M/d/yyyy" i want to convert the string to a date, while ensuring that the date matches the format. i also need to be able to specify the Y2K sliding window, pivot. This means that if a 2-digit y...

pointers and string parsing in c

I was wondering if somebody could explain me how pointers and string parsing works. I know that I can do something like the following in a loop but I still don't follow very well how it works. for (a = str; * a; a++) ... For instance, I'm trying to get the last integer from the string. if I have a string as const char *str = "some...

C# fails to parse NaN as a double

On a Windows PC in Japan, this line of C# throws a format exception: double d = double.Parse("NaN"); This line executes fine on my PC in the U.S. Don't know where to begin troubleshooting this one. Any thoughts? Thanks in advance, Jim ...

Java getQueryString

So im trying to capture a certian section of a getQueryString(). I know I could try and go through and parse the string to get the certain section I wanted but was hoping to just be able to grab the piece I need. Here is my query result: N=0&Ntk=General&Ntt=info&Nty=1&D=info&Ntx=mode+matchallpartial&Dx= mode+matchall Im looking just to...

Merge two field into One with only new items

I have two tables which both contain 'pipe separated values' e.g: Table 1: DataField_A item 1|item 2|item 3|etc..... Table 2: DataField_A item 7|item 5|item 3|etc..... I need to merge Table 2 into table 1 such that Table 2 contains all items across both tables. Doing this pro-grammatically would be a simple matter of loop...

How to read formatted data in C++?

I have a formatted data like the following: Words 5 AnotherWord 4 SomeWord 6 It's in a text file and I'm using ifstream to read it, but how do I separate the number and the word? The word will only consist of alphabets and there will be certain spaces or tabs between the word and the number, not sure of how many. ...