string-parsing

Parse varchar2 to table (Oracle)

北城以北 提交于 2020-01-17 08:43:10
问题 Is there built-in function in Oracle DB 11g r2 that could parse varchar2 variable to table? Opposite of listagg or wm_concat . I found only Tom Kyte 's method dated 2006: with data as ( select trim(substr (txt, instr(txt, ',', 1, level) + 1 , instr(txt, ',', 1, level + 1) - instr(txt, ',', 1, level) - 1)) as token from (select ',' || :txt || ',' txt from dual) connect by level <= length(:txt) - length(replace(:txt, ',', '')) + 1 ) select * from data; I think Oracle must have simpler way. 回答1:

Python: splitting a function and arguments

喜欢而已 提交于 2020-01-17 01:30:28
问题 Here are some simple function calls in python: foo(arg1, arg2, arg3) func1() Assume it is a valid function call. Suppose I read these lines while parsing a file. What is the cleanest way to separate the function name and the args into a list with two elements, the first a string for the function name, and the second a string for the arguments? Desired results: ["foo", "arg, arg2, arg3"] ["func1", ""] I'm currently using string searches to find the first instance of "(" from the left side and

DateTime.TryParse different results

孤街浪徒 提交于 2020-01-15 12:28:06
问题 As part of my unittests for an application I check a few datetime strings for their ability to get parsed. I recently noticed that on one machine the string "0-02-20 11:36" can get parsed to {2000-02-20 11:36:00} by DateTime.TryParse(dateString, out parsedTimeStamp) while on other machines it can't. string dt = "0-02-20 11:36"; DateTime parsedTimeStamp; DateTime.TryParse(dateString, out parsedTimeStamp); Console.WriteLine(parsedTimeStamp); 回答1: Parsing a DateTime , like all parsing in the

Extraction of some date formats failed when using Dateutil in Python

蹲街弑〆低调 提交于 2020-01-14 03:08:10
问题 I have gone through multiple links before posting this question so please read through and below are the two answers which have solved 90% of my problem: parse multiple dates using dateutil How to parse multiple dates from a block of text in Python (or another language) Problem : I need to parse multiple dates in multiple formats in Python Solution by Above Links : I am able to do so but there are still certain formats which I am not able to do so. Formats which still can't be parsed are:

Extraction of some date formats failed when using Dateutil in Python

孤街醉人 提交于 2020-01-14 03:08:06
问题 I have gone through multiple links before posting this question so please read through and below are the two answers which have solved 90% of my problem: parse multiple dates using dateutil How to parse multiple dates from a block of text in Python (or another language) Problem : I need to parse multiple dates in multiple formats in Python Solution by Above Links : I am able to do so but there are still certain formats which I am not able to do so. Formats which still can't be parsed are:

How to get Java version in a batch script subroutine?

馋奶兔 提交于 2020-01-06 06:44:54
问题 From this question: for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( @echo Output: %%g set JAVAVER=%%g ) How can I put this into a subroutine and call it, passing a path to the java executable? Here's an example of my problem: @echo off setlocal enabledelayedexpansion call :GET_JAVA_VER "java" goto END :GET_JAVA_VER for /f "tokens=3" %%g in ('%1 -version 2^>^&1 ^| findstr /i "version"') do @echo %%g %1 -version 2>&1 | findstr /i "version" goto :EOF :END endlocal

In JavaScript, How to extract latitude and longitude from string

安稳与你 提交于 2020-01-05 08:01:33
问题 I am extracting a string from a database which needs to be parsed into latitude and longitude separately, The string is defined as a "point", in the following format: (2.340000000,-4.50000000) I am trying to remove the parenthesis, and then parsed them with the method split() but I haven't been able to come up with a regular expressions that does the job right: So far I have tried many alternatives, and var latlong = "(2.34000000, -4.500000000)" latlong.replace('/[\(\)]//g',''); var coords =

In JavaScript, How to extract latitude and longitude from string

陌路散爱 提交于 2020-01-05 08:01:12
问题 I am extracting a string from a database which needs to be parsed into latitude and longitude separately, The string is defined as a "point", in the following format: (2.340000000,-4.50000000) I am trying to remove the parenthesis, and then parsed them with the method split() but I haven't been able to come up with a regular expressions that does the job right: So far I have tried many alternatives, and var latlong = "(2.34000000, -4.500000000)" latlong.replace('/[\(\)]//g',''); var coords =

StreamTokenizer splits up 001_to_003 into two tokens; how can I prevent it from doing so?

守給你的承諾、 提交于 2020-01-05 04:06:30
问题 Java's StreamTokenizer seems to be too greedy in identifying numbers. It is relatively light on configuration options, and I haven't found a way to make it do what I want. The following test passes, IMO showing a bug in the implementation; what I'd really like is for the second token to be identified as a word "20001_to_30000". Any ideas? public void testBrokenTokenizer() throws Exception { final String query = "foo_bah 20001_to_30000"; StreamTokenizer tok = new StreamTokenizer(new

Extracting relative paths from absolute paths

笑着哭i 提交于 2020-01-02 09:29:13
问题 This is a seemingly simple problem but I am having trouble doing it in a clean manner. I have a file path as follows: /this/is/an/absolute/path/to/the/location/of/my/file What I need is to extract /of/my/file from the above given path since that is my relative path. The way I am thinking of doing it is as follows: String absolutePath = "/this/is/an/absolute/path/to/the/location/of/my/file"; String[] tokenizedPaths = absolutePath.split("/"); int strLength = tokenizedPaths.length; String