browse by category or date

FYI, I am still slowly reading this book:

Today I reached a page where it gives example of how to use regular expression to split string shown below:

“Acme, Inc”,”Excalibur Pte Ltd”,”Blackrock, Pvt”

Into collection of sub-strings shown below:

Acme, Inc
Excalibur Pte Ltd
Blackrock, Pvt

The regex pattern that the book gives is:


var rgx = new Regex("(?:^|,)(?=[^\"]|(\")?)\"?((?(1)[^\"]*|[^,\"]*))\"?(?=,|$)");

When I saw this pattern, I was totally shell-shocked by my inability to comprehend it. So here’s my attempt to understand it. First, I am breaking the groups found within the pattern to help me digest it.

(?:^|,)

According to the documentation, (?:subPattern) is a non-capturing group. It means this pattern will match to the beginning of line or comma, but it will not create a new group.

(?=[^\"]|(\")?)

(?=subPattern) means Zero-width positive lookahead assertion. So we expect anything other than quote or a quote, appear after the previous group. But the matching string can still be use by the next group.

\"?((?(1)[^\"]*|[^,\"]*))\"?

This pattern will capture everything, except comma

(?=,|$)

Another non-capturing group that will match comma or end of the string

That’s all, I hope it helps!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Today I was testing my JSON Table Editor on Microsoft Edge browser. After a while, I realize it failed to close the child window. After testing the same functionality on other browsers (Mozilla Firefox, Opera, Google Chrome), I can confirm that this problem only occurred in Microsoft Edge (version shown below) and Microsoft Internet Explorer 11 (it still exists lurking under Edge’s shadow :D)

Since this should be a Microsoft Edge bug, I filed a bug report https://aka.ms/AA7nfw2 (Only Windows 10 users will be able to see this bug report). The bug report details is below:

1. visit https://sodeve.page.link/tvQxphqV41i3KAiw9

2. Click the calendar icon in Locations column, a new tab will open

3. On the new tab, click “Finish Editing”, the tab will close

4. Click the calendar icon in Locations column, any other row, new tab will open

5. On the new tab, click “Finish Editing”, tab is failed to close

On other browsers, step 5 always successfully close the tab.

I hope they will take a look into this ASAP!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Cannot be stressed enough, the importance of social responsibility:

[Sent by Gov.sg – 11 Mar]

COVID-19: Social responsibility is critical

➡Many locally transmitted cases were caused by individuals attending social activities though sick
– 35 of 160 confirmed cases did not minimise social contact even with symptoms
– 22% went to work
– 24% doctor hopped; 8 visited three or more

Protecting our seniors
– All senior-centric activities by government agencies will be suspended for 14 days (till 24 Mar 2020)
– Care services for seniors will continue, with added precautions
– All who are sick should see a doctor and stay at home

More: go.gov.sg/PAseniors

Two clusters caused by socially irresponsible behaviour: go.gov.sg/clusters

Updates on the number of confirmed and discharged cases:

[Sent by Gov.sg]

COVID-19: 11 Mar Update

As of 12pm:
New cases: 12
Total cases in Singapore: 178
Discharged today: 3
Total discharged: 96
Total remaining in Hospital: 82

Of the new cases, 1 is part of the SAFRA Jurong cluster, 8 are imported cases, 1 is linked to an imported case, and 2 are unlinked.

Most in hospital are stable or improving. 9 are in the intensive care unit – three less than yesterday.

go.gov.sg/moh11mar

Stay safe everyone!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: