delimiter

Java parsing string

情到浓时终转凉″ 提交于 2019-12-22 10:55:57
问题 I'm looking to parse the following string in java <some lines here> Key1:thingIWantToKnow Key2:otherThing Key3:bla Key4:bla Key5:bla <(possibly) more lines here> All lines end with a newline (\n) character. I'm looking to store the value pair once I find the key's I'm care about. 回答1: If a Map is what you want: Map<String, String> keyValueMap = new HashMap<String,String>(); String[] lines = input.split("\n"); if (lines == null) { //Compensate for strange JDK semantics lines = new String[] {

Change lines that match a pattern in between delimiters using awk

假装没事ソ 提交于 2019-12-22 10:46:04
问题 I have an input file something like this: some line some other line another line start_delimiter interesting stuff more interesting stuff even more interesting stuff end_delimiter possibly more stuff I want to manipulate the lines between start_delimiter and end_delimiter that match a regex pattern and write the results to the input file. For example, add '//' to the beginning of the lines containing the word 'more' (as long as those lines are between the delimiters): some line some other

Replacing delimiter characters in file path

こ雲淡風輕ζ 提交于 2019-12-22 08:09:49
问题 I'm developing a C# web application in VS 2008. I let the user select an input file and then I store the file path in a string variable. However, it stores this path as "C:\\folder\\..." . So my question is how do I convert this file path into single "\"? Thank you guys for all your helps! Please forgive me as I am a newbie to ASP.NET development. This is more of my code in context. First I want to see if the directory exists. I guess I don't have to check this if I check if the file exists.

Java CSV parser with string separator (multi-character)

谁说胖子不能爱 提交于 2019-12-22 03:23:14
问题 Is there any Java open source library that supports multi-character (i.e., String with length > 1) separators (delimiters) for CSV? By definition, CSV = Comma-Separated Values data with a single character (',') as the delimiter. However, many other single-character alternatives exist (e.g., tab), making CSV to stand for "Character-Separated Values" data (essentially, DSV: Delimiter-Separated Values data). Main Java open source libraries for CSV (e.g., OpenCSV) support virtually any character

Escaping colons in YAML

一个人想着一个人 提交于 2019-12-22 01:33:19
问题 Does anyone know how to escape colons in YAML? The key in my yml is the domain with port number, but the yml file isn't working with this setup: ###BEGIN production: ### THIS IS THE ONE I'm HAVING TROUBLE WITH ### 8.11.32.120:8000: GoogleMapsKeyforThisDomain exampledomain.com: GoogleMapsAPIKeyforThatDomain development: GoogleMapsAPIKeyforDevelopmentDomain ###END I'm using a google maps plugin called YM4R that uses a .yml file to select the different Google Maps API key depending on where my

Ruby : How can I detect/intelligently guess the delimiter used in a CSV file?

让人想犯罪 __ 提交于 2019-12-21 12:30:08
问题 I need to be able to figure out which delimiter is being used in a csv file (comma, space or semicolon) in my Ruby project. I know, there is a Sniffer class in Python in the csv module that can be used to guess a given file's delimiter. Is there anything similar to this in Ruby ? Any kind of help or idea is greatly appreciated. 回答1: Looks like the py implementation just checks a few dialects: excel or excel_tab. So, a simple implementation of something that just checks for "," or "\t" is:

C# StreamReader, “ReadLine” For Custom Delimiters

冷暖自知 提交于 2019-12-21 07:13:39
问题 What is the best way to have the functionality of the StreamReader.ReadLine() method, but with custom (String) delimiters? I'd like to do something like: String text; while((text = myStreamReader.ReadUntil("my_delim")) != null) { Console.WriteLine(text); } I attempted to make my own using Peek() and StringBuilder , but it's too inefficient. I'm looking for suggestions or possibly an open-source solution. Thanks. Edit I should have clarified this earlier...I have seen this answer, however, I'd

How to parse a file with special delimiters in a batch file?

笑着哭i 提交于 2019-12-20 06:18:42
问题 I want to parse a file that looks like this using batch : a: string_containing_various_characters,.:and spaces/1 b: string_containing_various_characters,.:and spaces/2 c: string_containing_various_characters,.:and spaces/3 d: string_containing_various_characters,.:and spaces/4 e: string_containing_various_characters,.:and spaces/5 f: string_containing_various_characters,.:and spaces/6 g: string_containing_various_characters,.:and spaces/7 I need to extract every string following "a: ","b: ",

Regex results in “Delimiter must not be alphanumeric or backslash” [duplicate]

白昼怎懂夜的黑 提交于 2019-12-20 06:03:35
问题 This question already has answers here : Delimiter must not be alphanumeric or backslash and preg_match (7 answers) Troubleshooting “Delimiter must not be alphanumeric or backslash” error when changing ereg() to preg_match() [duplicate] (2 answers) Closed 6 years ago . I have this code function a($menu_item, $remove_link) { $pattern = 'class="(.+)"(.+)<a.+>(.+)</a>'; if($remove_link) { return preg_replace($pattern, 'class="$1 selected"$2$3', $menu_item); //<- line 6 } return $menu_item; }

BASH SHELL: Using awk, with a delimiter, 2 search terms

半腔热情 提交于 2019-12-20 05:29:12
问题 I'm very new to BASH Shell programming. Here's my issue, I need to split data from my file (with a semicolon delimiter) and search if a certain book exists. file contents: Harry Potter - The Half Blood Prince:J.K Rowling:40.30:10:50 The little Red Riding Hood:Dan Lin:40.80:20:10 Harry Potter - The Phoniex:J.K Rowling:50.00:30:20 Harry Potter - The Deathly Hollow:Dan Lin:55.00:33:790 Little Prince:The Prince:15.00:188:9 Lord of The Ring:Johnny Dept:56.80:100:38 Three Little Pig:Andrew Lim:89