Questions tagged [string-parsing]

The action of retrieving data from a string

String parsing is the action of extracting or modifying data pieces from a string. For example, one might parse a string to remove all quotation marks or to find all items inside quotation marks.

970 questions
3
votes
3 answers

how to turn a string of letters embedded in squared brackets into embedded lists

I'm trying to find a simple way to convert a string like this: a = '[[a b] [c d]]' into the corresponding nested list structure, where the letters are turned into strings: a = [['a', 'b'], ['c', 'd']] I tried to use import ast l =…
DaniPaniz
  • 1,058
  • 2
  • 13
  • 24
3
votes
1 answer

How to pass json value to API using post in c#?

I am new to c#,can you tell me what is best way to pass json value to API in c# using POST. Below I have written python code, but not sure how to do it in c#. string payload = { "username" : "1432143352759a61bca0ad4a35a4f0", # when you register,…
nikunjM
  • 560
  • 1
  • 7
  • 21
3
votes
3 answers

Parsing a number from a string with thousands seperators

i'm parsing out Long values from given String-s. Long.valueOf() and Long.parseLong() wouldn't work - because such a String str is in the format 1,234,567 and can be surrounded by spaces. I can work this by processing the String to get it to bare…
user4402742
  • 91
  • 1
  • 11
3
votes
2 answers

Extract data between two delimiters

I just want to know whether it is possible to pick up the data that is present between two delimiters (delimiter being a string). For example the original string is as…
k.dev
  • 57
  • 1
  • 3
3
votes
4 answers

Remove lines containing certain substring in Golang

How to remove lines that started with certain substring in []byte, in Ruby usually I do something like this: lines = lines.split("\n").reject{|r| r.include? 'substring'}.join("\n") How to do this on Go?
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
3
votes
5 answers

Read a list of numbers from string

I want to read a list of space - separated numbers stored in a string. I know how this can be done using stringstream in C++ -: string s = "10 22 45 67 89"; stringstream ss(s); int numbers[100]; int k=0, next_number; while(ss>>next_number) …
Anmol Singh Jaggi
  • 8,376
  • 4
  • 36
  • 77
3
votes
5 answers

Parse hour and AM/PM value from a string - C#

What would be the most effective way to parse the hour and AM/PM value from a string format like "9:00 PM" in C#? Pseudocode: string input = "9:00 PM"; //use algorithm //end result int hour = 9; string AMPM = "PM";
Michael Kniskern
  • 24,792
  • 68
  • 164
  • 231
3
votes
2 answers

Removing string parts between substrings when substrings occur multiple times in R

In a string string="aaaaaaaaaSTARTbbbbbbbbbbSTOPccccccccSTARTddddddddddSTOPeeeeeee" I would like to remove all parts that occur between START and STOP, yielding "aaaaaaaaacccccccceeeeeee" if I try with gsub("START(.*)STOP","",string) this gives…
Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
3
votes
5 answers

Is there better way to extract key/values from string like this

I have following string: OK: I use this method to parse and get result: public string MethodName(string capt) { var receivedData = capt.Split(' ').ToArray(); …
1110
  • 7,829
  • 55
  • 176
  • 334
3
votes
6 answers

Parse all column elements from a linux bash command output

I would like to parse the column elements of the output from the command lsscsi. Here is a sample output, # lsscsi [0:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda [0:0:1:0] disk ATA VBOX HARDDISK 1.0 /dev/sdb [1:0:1:0] disk …
user2887201
  • 317
  • 2
  • 9
  • 19
3
votes
2 answers

How can I convert a string to a float with Perl?

Is there any function like int() which can convert a string to float value? I'm currently using the following code: $input=int(substr($line,1,index($line,",")-1)); I need to convert the string returned by substr to float.
fixxxer
  • 15,568
  • 15
  • 58
  • 76
3
votes
1 answer

In Lua, how to parse out a http(s) string from a long string?

If I have a string, such as This is a website, it is at http://www.abc.com/post_id?id=123&key=456, please visit it and let me know. Thanks How to parse this string in Lua, so I can obtain three substrings: String 1 - the texts before the…
Joe Huang
  • 6,296
  • 7
  • 48
  • 81
3
votes
2 answers

Parsing a string into parts, only consecutive words, not a power set

I'm trying to write a search query to find articles from a database. I would like to take the search string the user enters and look for a specific set of possible search terms. If the user entered the search string "listing of average salaries in…
Justin808
  • 20,859
  • 46
  • 160
  • 265
3
votes
1 answer

Read line containg only string and merge content to previous line

Input is:

1:4 And David said unto him, How went the matter? I pray thee, tell me.

And he answered, That the people are fled from the battle, and many of the people also are fallen and dead; and Saul and Jonathan his son are dead…

TinKerBell
  • 2,111
  • 2
  • 14
  • 12
3
votes
2 answers

Regular Expressions - Matching IRC-like parameters?

I am looking to create a IRC-like command format: /commandname parameter1 "parameter 2" "parameter \"3\"" parameter"4 parameter\"5 Which would (ideally) give me a list of parameters: parameter1 parameter 2 parameter…
Steffan Donal
  • 2,244
  • 4
  • 24
  • 47