« first day (934 days earlier)      last day (2858 days later) » 

3:42 AM
@MartinBüttner The first one should be !b!!b!. I guess .NET keeps the match for named capturing group separate from the numbered groups, so it's rather hard to tell for the rest.
It seems my guess about named capturing group being kept separately is correct, and the 3rd case is the trap case
Anyway, I don't get the use of $+
 
 
5 hours later…
9:00 AM
Hey guys, How do I pick the values and the country from something like this

```5 Ireland - 7 romania #spread
Romania 7 - Ireland 5 #spread
5 Ireland-7 Romania #spread
Romania 7-Ireland5#spread```

Ideally, I want to obtain the data in this format {Ireland: 5, Romania: 7}
 
is that Golang?
 
9:26 AM
I wanted to do it in ruby or javascript
The result would just be a normal json string
 
@nhahtdh Yes, correct. $+ indeed seems pretty pointless the way it's implemented (and it's not exactly the way it's documented)
Although it's not that named capturing groups are being kept separate: it's that they also receive numbers, but only after all the unnamed ones have been numbered.
So in case 3 (?<a>a) is actually group 2.
 
9:52 AM
@Mutuma kind of hard to do with a single expression. You'll need to manipulate the resulting list/array
 
10:19 AM
How would I manipulate something like "Romania 7 - Ireland 5 #spread" to give me {romania: 7, ireland: 5}

First, I would downcase all the characters in the string then use a regex to filter.
I have never done regex before, I am learning using rubular.com but I am unsure of how to associate the words with the picked digits
@Jerry ... see above
 
@Mutuma Yes, what you can do is something like that, but like I said, you'll have to have something else to sort it out after getting the small bits
/
(?:                   # Begin group
  (\d+) *([a-z]+)     # Digits, any spaces, letters
|                     # OR
  ([a-z]+) *(\d+)     # letters, any spaces, digits
)                     # close group
/i                    # ignore case
you will see in the results that there are lots of empty strings returned. I don't know much of ruby if at all though.
I can't help you to sort/filter out the blanks
basically, I'd test each element of the resulting list/array, if it is number, put it in the json string as the value, else as the key. If it is blank, ignore and verify the next set of matches
 
Hehe, I think i have identified a simpler way, Iterate through all characters, once I hit a number, I take the previous word. Though a regex is much more performance friendly since I am thinking of plugging this to the twitter streaming API
 
10:56 AM
^ I'm not so sure about "performance friendly". It's a quick way to get things done, though
@MartinBüttner Is it? Then how does it order the matches in aaaaaaaaaaaaabbbbbbbbbaaaaaaaaabbbbbbbbbb for ((?<a>a)*(?<a>b)*){2}
Never mind my question. It seems that the case above only has 2 capturing groups
Both named capturing groups writes into the same capturing group
This might make a nice question on the main site
 
11:17 AM
@nhahtdh It gets even funnier with something like ((?<a>a)*(?<2>b)*(c)*){2}
 
 
9 hours later…

« first day (934 days earlier)      last day (2858 days later) »