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
2
votes
3 answers

NumberFormatException: For input string: ""?

Code int weight = 0; do { System.out.print("Weight (lb): "); weight = Integer.parseInt(console.nextLine()); if (weight <= 0) { throw new IllegalArgumentException("Invalid weight."); } } while (weight <= 0); Traceback Weight…
2
votes
1 answer

How to set Font from String in Java

I have an CMS application which is written using C#, and I should Save FONT's as VARCHAR in a Database. Then I should get the specified FONT from a Java Application. So how is possible to set a Font to a JLabel or a Font Object using String. For…
Rosmarine Popcorn
  • 10,761
  • 11
  • 59
  • 89
2
votes
1 answer

Numberformat does not change cell value in vba excel

I have a range of numbers formatted as text in column A that represent date: 02 10 'which means 02 October 03 11 'which means 03 November 04 12 'which means 04 December What I'm trying to do is to parse this string in order to turn it into a…
2
votes
4 answers

How to parse this string in python using regex?

I have the following string in python: text = "vagrant 11450 4344 0 Feb22 pts/2 00:00:28 python run.py abc" I want to capture the text after time field that is "python run.py abc" I am using the following regex but it is not working [\d:]+…
Saifullah khan
  • 686
  • 11
  • 19
2
votes
2 answers

Extract certain text of a string using mysql

I have the following string: https://scontent-sjc3-1.xx.fbcdn.net/v/t1.0-1/p200x200/26056120_2094108927485604_7093424189760207868_n.png What I want is to keep only: 26056120_2094108927485604_7093424189760207868_n.png I already tried using LOCATE…
2
votes
1 answer

Is JSON parsing or String parsing more expensive in Java?

I'm trying to dynamically parse a lot of data in Java. In other words I have tons of different types of data so I am putting them in a String or a JSON String (via GSON) instead of doing: switch(data){ case instanceof Class1: Class1 data =…
Tacitus86
  • 1,314
  • 2
  • 14
  • 36
2
votes
1 answer

Extraction of some date formats failed when using Dateutil in Python

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…
Rahul Agarwal
  • 4,034
  • 7
  • 27
  • 51
2
votes
1 answer

Parse integer string as decimal, octal or hex depending upon prefix

I want to parse a string that contains a number in either decimal, octal or hex formats, and I want to do so with zero heap allocations. Therefore Regex and substrings are out. The base is determined via a prefix: 1234 is decimal 01234 is octal due…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
2
votes
1 answer

How to check if string is a valid inquiry

I need to ensure that certain strings are valid questions. I am thinking of how to write this myself, but without being pretty limiting it is actually a fairly complex bit of analysis, and I'm sure it must have been done many times before. I'm not…
James Trickey
  • 1,322
  • 13
  • 21
2
votes
3 answers

Find URLs in .NET?

Given a list of strings, I'm interested in finding which ones are valid http:// URLs. My first approach would be to use a regex and do something like this: var urls = strs.Where(str => urlRegex.matches(str)); Is there a more idiomatic/natural/simple…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
2
votes
2 answers

Is it possible to parse string without GC allocations?

I need to parse NMEA data from build-in GPS receiver in Android device. I'm receiving this data few times per second as a string. I'm curious is it possible to do this without garbage collection allocations or parsing strings is one of this moments…
seek
  • 1,065
  • 16
  • 33
2
votes
2 answers

How to get os.Args-like tokens from a command line string

I have a string variable: commandLineString := `echo -n "a b c d"` I want to covert it to: args := []string{"echo", "-n", "\"a b c d\""} How can I do it?
chengbin du
  • 512
  • 4
  • 13
2
votes
4 answers

parsing blocks of text within a text file (blocks separated by empty line)

I'm a brand new Python user who wants to parse a text file that looks like this: $ begin $ vertex -1285.6 -226.2 -538.7 0 $ track 11 1000 0.7277 0.6765 0.1133 0 $ end $ begin $ vertex -1265.3 573.1 1547.7 0 $ track 11 1000 -0.7679 0.1650 0.6189 0 $…
2
votes
2 answers

Dividing a string using regular expression in C#

I have a string like this : "John William Doe 250 / 1000 Adam Smith 500 / 1000 Jane Black 250 / 1000" As you can see, the string consists of people's names and their shares. There can be any number of people (and shares) and people's names can…
jason
  • 6,962
  • 36
  • 117
  • 198
2
votes
3 answers

Split string multiple patterns

I have a string of form "Some lengthy string, Pattern1: string1, Pattern2: string2, Pattern3: string3". My objective is to extract string1, string2 and string3 from such a String. Note that the Strings, Pattern1, Pattern2 and Pattern3 themselves…
cplusplusrat
  • 1,435
  • 12
  • 27