Matching an optional substring in a regex

I'm developing an algorithm to parse a number out of a series of short-ish strings. These strings are somewhat regular, but there's a few different general forms and several exceptions. I'm trying...

Overlapping matches in Regex

I can't seem to find an answer to this problem, and I'm wondering if one exists. Simplified example: Consider a string "nnnn", where I want to find all matches of "nn" - but also those that...

Python parse comma-separated number into int

Possible Duplicate: How do I use Python to convert a string to a number if it has commas in it as thousands separators? How would I parse the string 1,000,000 (one million) into it's integer...

Is there any connection string parser in C#?

I have a connection string and I want to be able to peek out for example "Data Source". Is there a parser, or do I have to search the string?

Javascript object Vs JSON

I want to understand the basic differences clearly between Javascript object and JSON string. Let's say I create the following JS variable: var testObject = {one: 1,"two":2,"three":3}; Q1. Is...

What is the difference between `throw new Error` and `throw someObject`?

I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code. When I did throw new Error('sample') like in the following code try { throw...

How to parse a date in format "YYYYmmdd" in JavaScript?

This is a noob question: How to parse a date in format "YYYYmmdd" without external libraries ? If the input string is not in this format I would like to get invalid Date (or undefined if it will...

node.js with express how to remove the query string from the url

I have a button that is performing a get to my page and adding a filter to the query string. My code applies that filter to the grid but the user can remove/edit that filter. Since they can see...

Copy and transform a file using Node.js

I want to copy some files using Node.js. Basically, this is quite easy, but I have two special requirements I need to fulfill: I need to parse the file's content and replace some placeholders by...

Error Using std::vector<std::string> myString

Hi it's a little bit hard for me to understand what the compiler is saying: [BCC32 Error] frmNew.cpp(333): E2285 Could not find a match for...

How to do date/time comparison

Is there any options in doing date comparison in Go? I have to sort data based on date and time - independently. So I might allow an object that occurs within a range of dates so long as it also...

Validate URL query string with regex

I'm trying to validate a query string with regex. Note that I'm not trying to match out the values, but validate its syntax. I'm doing this to practice regex, so I'd appreciate help rather than...

C# How to use FirstOrDefault with an array while unable to have System.Linq in the namespace?

The code provided here works when I test it in the IDE, but the software itself which will be using this code doesn't give me the possibility declare using System.Linq. I'm stuck trying to figure...

simple html dom parser: fix missing quotes of attributes

i'm using simple html dom parser for batch-fixing errors in html markup, such as missing quotes like <div class=foo></div> my code: $els = $doc->find("div[class]"); foreach($els as...

How to do an unpretty print on pretty JSON file in shell >> serial string JSON >> ES _bulk?

In working with Elasticsearch on AWS EC2, I just hit an issue with bulk indexing. The ES _bulk endpoint requires the files to be basically JSON serial strings with \n terminators on each string;...

Swift Get string between 2 strings in a string

I am getting a string from html parse that is; string = "javascript:getInfo(1,'Info/99/something', 'City Hall',1, 99);" my code is something like var startIndex = text.rangeOfString("'") var...

Expand $BASH_COMMAND preferably without eval

As part of an error handling function, I need to report the currently executing command when an error is trapped. The bash $BASH_COMMAND string contains the command, but with nested non-expanded...

getYear(), getMonth(), getDay are deprecated in Calendar, what to use then?

I want to parse a date from a string and set it in the DatePickerDialog: try { myCalendar.setTime(mySimpleFormatter.parse(jsonObj.getString("dob"))); } catch (ParseException e) { ...

How to parse query string in react-router v4

In react-router v3 I could access it with props.location.query.foo (if the current location was ?foo=bar) In [email protected] props.location only has props.location.search with is a string...

How to print a ViewBag string that was populated within a try/catch block

I am parsing a JSON file in my controller and have try/catch functionality. The catch for the JSON populates the ViewBag and I want to print it in the view if there is an error. However the...

How to read a CSV from a string?

I have some data in a csv format. However they are already a string, since i have got them from an HTTP request. I would like to use Data Frames, in order to view the data. However i don't know...

Custom spring security filter not called at runtime

I'm trying to enable spring security in a spring boot rest services project and I'm getting some problems. I configured it with this code @Configuration @EnableWebSecurity public class WebSecurity...

Pymongo bson.errors.InvalidDocument: Cannot encode Object when read from file

I have a csv file with a header row and 100k entries in it. I am using python in pycharm IDE and conda as python interpreter. conda suppies pymongo-3.4.0 as mongo-driver. I parse my csv file and...

Parse gt06 GPS string

i've the following string from the Gt06 v3 gps: 12060e163121c8020f9bf20aa06bad371d52014e03235a008a7d00269dfe0d But i don't know how to parse to string and extract the latitude and logitude, any ideas?

remove null character from string

I want to check if string is empty and parse the string in time. Please find the below code valueStr = strings.Replace(string(valueStr), " ", "", -1) valueStr = strings.Replace(string(valueStr),...

Rust: Parse user input String with clap for command line programming

I'd like to create a command line that utilizes clap to parse input. The best I can come up with is a loop that asks the user for input, breaks it up with a regex and builds a Vec which it somehow...

Elastic Beanstalk with Docker running on 64bit Amazon Linux 2/3.2.2 and Dockerrun.aws.json v3

Could somebody please point me to the correct Dockerrun.aws.json v3 documentation. I have done google many times and unable to find this v3 documentation. I am trying to do multi-container...

BigQuery: Format ISO Date

I'm trying to parse a timestamp which is in ISO Date 8601 format. Example: 2021-04-10T14:11:00Z This information is stored inside a JSON object and for that reason I'm extracting that data as a...

Optimizing a file content parser class written in TypeScript

I got a typescript module (used by a VSCode extension) which accepts a directory and parses the content contained within the files. For directories containing large number of files this parsing...

How to connect to AWS CodeCommit with ssh credentials?

Have a problem with connecting to CodeCommit with ssh. It seems I do all that needs. generate key , give him access rights, put in AWS IAM pubkey for user with roles for code commit. create config...

Relevant tags