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
24
votes
5 answers

In JavaScript / jQuery what is the best way to convert a number with a comma into an integer?

I want to convert the string "15,678" into a value 15678. Methods parseInt() and parseFloat() are both returning 15 for "15,678." Is there an easy way to do this?
David
  • 2,834
  • 6
  • 26
  • 31
21
votes
6 answers

javascript, regex parse string content in curly brackets

i am new to regex. I am trying to parse all contents inside curly brackets in a string. I looked up this post as a reference and did exactly as one of the answers suggest, however the result is unexpected. Here is what i did var abc =…
MengQi Han
  • 310
  • 1
  • 3
  • 9
18
votes
4 answers

Remove all hex characters from string in Python

Although there are similar questions, I can't seem to find a working solution for my case: I'm encountering some annoying hex chars in strings, e.g. '\xe2\x80\x9chttp://www.google.com\xe2\x80\x9d blah blah#%#@$^blah' What I need is to remove these…
Kludge
  • 2,653
  • 4
  • 20
  • 42
18
votes
7 answers

What is a good python parser for a google-like search query?

For some search-based code (in Python), I need to write a query syntax parser that would parse a simple google like query syntax. For example: all of these words "with this phrase" OR that OR this site:within.site filetype:ps from:lastweek As…
Boaz
  • 25,331
  • 21
  • 69
  • 77
16
votes
1 answer

HEX to HSL convert javascript

Hello I'm trying to create HEX to HSL converter function. I know that at first I should convert HEX to RGB and then from RGB to HSL. I've done so using some script from StackOverflow. S and L is working correctly but H (hue) is not. I do not know…
BT101
  • 3,666
  • 10
  • 41
  • 90
15
votes
4 answers

Remove blank lines in a text file

How can you remove blank lines from a text file in C#?
Mike
  • 239
  • 1
  • 2
  • 5
15
votes
4 answers

How to read formatted data in C++?

I have formatted data like the following: Words 5 AnotherWord 4 SomeWord 6 It's in a text file and I'm using ifstream to read it, but how do I separate the number and the word? The word will only consist of alphabets and there will…
TheOnly92
  • 1,723
  • 2
  • 17
  • 25
15
votes
4 answers

Regex with non-capturing group in C#

I am using the following Regex JOINTS.*\s*(?:(\d*\s*\S*\s*\S*\s*\S*)\r\n\s*)* on the following type of data: JOINTS DISPL.-X DISPL.-Y ROTATION 1 0.000000E+00 0.975415E+01 …
ian93
  • 1,488
  • 4
  • 24
  • 37
14
votes
4 answers

Parse ISO timestamp using Java 8 java.time api (standard edition only)

I'm having trouble getting milliseconds from the epoch out of the string in the example. I have tried this three different ways so far, and the example shows the latest attempt. It always seems to come down to that the TemporalAccessor does not…
Travis Wellman
  • 375
  • 1
  • 2
  • 8
14
votes
4 answers

Equivalent for pop on strings

Given a very large string. I would like to process parts of the string in a loop like this: large_string = "foobar..." while large_string: process(large_string.pop(200)) What is a nice and efficient way of doing this?
Martin Flucka
  • 3,125
  • 5
  • 28
  • 44
12
votes
4 answers

Does OCaml have String.split function like Python?

I am using this to split strings: let split = Str.split (Str.regexp_string " ") in let tokens = split instr in .... But the problem is that for example here is a sentence I want to parse: pop esi and after the split it turns to be (I use…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
11
votes
3 answers

java generic String to parser

Is there a straight-forward way to implement a method with the following signature? At minimum, the implementation would need to handle primitive types (e.g. Double and Integer). Non-primitive types would be a nice bonus. //Attempt to instantiate an…
cqcallaw
  • 1,463
  • 3
  • 18
  • 29
11
votes
2 answers

Parsing all possible types of varying architectural dimension input

I am writing a library for our company's product that will take any kind of architectural dimension that our users are already familiar with as input for a function that converts from a string to a double. Here is the list of input types that we…
jth41
  • 3,808
  • 9
  • 59
  • 109
11
votes
6 answers

take the last n lines of a string c#

I have a string of unknown length it is in the format \nline \nline \nline with out know how long it is how can i just take the last 10 lines of the string a line being separated by "\n"
user1588670
  • 283
  • 1
  • 3
  • 13
11
votes
5 answers

Get root domain from location.host

There are a lot of SO questions that seem to address variations of this question. But they tend to be complex regex answers and I am hoping I can find something simpler. Given location.host values…
mrtsherman
  • 39,342
  • 23
  • 87
  • 111
1
2
3
64 65